Skip to content

Instantly share code, notes, and snippets.

View dean-huczok's full-sized avatar

Dean Huczok dean-huczok

  • Tokyo
View GitHub Profile
@burkeholland
burkeholland / FileReader.md
Last active September 30, 2022 08:12
Reading A Local JSON File With NativeScript

In NativeScript, the http module doesn't currently support making network requests to the local file system. That work is intended to be done by the file reader. It's pretty simple to read a local file and parse its contents as JSON.

This is the TypeScript/Promise version of what Emil Oberg created for the same question on StackOverflow. This module should be reusable for any and all asyncronous local JSON read operations.

import * as fs from 'file-system';

var documents = fs.knownFolders.currentApp();

class FileReader {