快递服务器未发送响应

时间:2018-10-17 13:55:20

标签: node.js express

我有以下代码:

路线:

router.get('/students', function(req, res,next) {

    studentsApi.getAllStudents(function(err, items) {

        res.json( {student:items});
    })
});

api.js:

let jsonData= require('./students');

let jsoneData=JSON.parse(jsonData);
let _copy = function(item) {
    return JSON.parse(JSON.stringify(item));
};

let studentsApi = {
    getAllStudents: function(callback) {
        callback(null, _copy(jsoneData));
    }
}
module.exports = studentsApi;

我可以在localhost:3000上看到默认的快递页面,但是localhost:3000/students返回 404错误。学生是一个js文件

0 个答案:

没有答案