gpt4 book ai didi

javascript - 如何将路由器/中间件添加到Features应用程序?

转载 作者:太空宇宙 更新时间:2023-11-04 02:44:56 25 4
gpt4 key购买 nike

我已将路由器添加到我的 Feathers 应用程序中,如下所示

app.use('/test', (req, res) => {
res.json({
message: 'Hello world from Express middleware'
});
});

应用程序运行于http://localhost:3030/当我向 http://localhost:3030/test 发送 get 请求时从 postman 我收到以下错误

{
"name": "NotFound",
"message": "Page not found",
"code": 404,
"className": "not-found",
"data": {
"url": "/test"
},
"errors": {}
}

我该如何解决这个问题?感谢期待。

最佳答案

我认为你的代码应该是:

  app.get('/test', (req, res) => {
res.json({
message: 'Hello world from Express middleware'
});
});

关于javascript - 如何将路由器/中间件添加到Features应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59352603/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com