@zic10 wrote:
I have an external JSON file that I would like to load and read the contents of. I downloaded the
cordova-plugin-file
and I'm trying to read this file using the plugin. However I'm not sure where the JSON file needs to be placed in the ionic project. I assume it needs to be somewhere in thewww
folder. I created a 'data' folder with a path that would bewww/data/myfile.json
. I've tried various approaches to read this file and all of them have failed to find it.$cordovaFile.checkFile(cordova.file.dataDirectory, "myFile.json") .then(function(success) { alert("Successfully found the directory"); }, function (error) { alert("Failed to find the directory"); });
I've tried different directories including: dataDirectory, applicationDirectory, and applicationStorageDirectory. However all of these directories give me the error callback. If anyone has tips or suggestions on how to properly read a file that is located within the project directory that would be much appreciated.
Thanks!
Posts: 2
Participants: 2