首页 > 解决方案 > 快递服务器不发送响应

问题描述

我有以下代码:

路线:

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:3000localhost:3000/students返回404 错误。学生是一个js文件

标签: node.jsexpress

解决方案


推荐阅读