Answer the question
In order to leave comments, you need to log in
What is the error when accessing the JSON file?
Good afternoon!
When requesting a JSON file, the console gives an error:
SyntaxError: Unexpected token in JSON at position 0
var fs = require("fs");
fs.readFile("text.json", function(err, data) {
if (err) throw err;
var arr = data.toString();
arr = JSON.parse(arr);
console.log(arr.title);
});
JSON:
{
"title": "Закрыть",
"action": "CloseDoc"
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question