我已如下所示向我的羽毛应用添加了路由器
app.use('/test', (req, res) => {
res.json({
message: 'Hello world from Express middleware'
});
});
当我从邮递员向http://localhost:3030/发送获取请求时,应用程序在http://localhost:3030/test上运行,我得到以下错误
{
"name": "NotFound",
"message": "Page not found",
"code": 404,
"className": "not-found",
"data": {
"url": "/test"
},
"errors": {}
}
我该如何解决?谢谢您。
答案 0 :(得分:-1)
我认为您的代码应为:
app.get('/test', (req, res) => {
res.json({
message: 'Hello world from Express middleware'
});
});