1

I'm trying to read a json file using node js/ express and deploying it to parseCloud but i keep getting

*Failed to load filters.json with: Could not find file filters.json *

here is my code:

var fs = require('fs');
var obj = JSON.parse(fs.readFileSync('cloud/filters.json', 'utf8'));

or this

var filterJson = require('cloud/filters.json');

thanks

2 Answers 2

3

Looks like parse.com doesn't allow .json files. You can save your file as .js and load it as plain text file (doesn't work with require()).

var fs = require('fs');
var parsedObject = JSON.parse(fs.readFileSync('cloud/path/json_file.js'));

It looks ugly, but works for me. :)

Sign up to request clarification or add additional context in comments.

Comments

-1

Try to add ./

fs.readFileSync('./cloud/filters.json', 'utf8')

1 Comment

Invalid file path: ./cloud/filters.json path must start with cloud/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.