node.js - 快递服务器不发送响应
问题描述
我有以下代码:
路线:
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文件
解决方案
推荐阅读
- html - 修改 blogdown webst 的 font-title
- variables - 来自具有动态值的 HTML 属性的 LESS 变量
- html - Bootsrap 4使用Angular 8将输入文本作为只读响应
- dataweave - Dataweave 中的尾递归
- matlab - 如何修复“索引超过数组元素的数量 (1)”错误?
- xml - 需要根据其中一个 XML 标签更改编码格式
- java - 调用内部带有 for 循环的方法,而不是更新变量
- javascript - Discord Bot 生成错误:“消息未定义”
- c++ - 指向 C++ 中函数的指针,(*pf)() 和 pf 是否相同?
- bash - 了解为什么 git-filter-branch 没有清理我的历史记录