Düğüm numaralı json dosyasını ayrıştırmayı denedim ancak her zaman hata var ve ben google onu ama çözemiyorum. Bana yardım edebilir misin?Node.JS JSON.parse error undefined
undefined:1
undefined
^
SyntaxError: Unexpected token u
at Object.parse (native)
at Object.<anonymous> (app.js:13:19)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
bu benim kod
var app = express();
var mongodb = require("mongoskin");
var fs = require('fs');
var content;
fs.readFile('./config/db.json', function read(err, data) {
if (err) {
throw err;
}
content = data;
});
var config = JSON.parse(content);
app.get('/', function(req, res){
res.send(config.left);
});
app.listen(process.env.VCAP_APP_PORT || 3000);
var ve db.json budur. Gördüğünüz gibi hata yok.
{
"left": 3
}
js için yeni duyuyorum work..I sayesinde okumak tavsiye düşünmek götürüyor. –