我正在尝试从json文件中获取数据,但是当我运行程序时,它会给我一个内部服务器错误。这是我的代码,请帮助我。
var express = require('express');
var router = express.Router();
var fs = require('fs');
var logs;
router.get('/', function(req, res, next) {
res.send('nothing to show please find appropriate url');
});
router.get('/data', function(req , res , next ){
var filename = process.argv[3]
fs.readFile('/home/malik/Desktop/a.json', function(e, data) {
if (e) return res.sendStatus(500)
try {
books = JSON.parse(data)
} catch (e) {
res.sendStatus(500)
}
res.json(logs)
console.log(logs,"logs");
})
});
module.exports = router;