如何将路由器/中间件添加到羽毛应用程序?

时间:2019-12-16 08:06:55

标签: javascript node.js router feathersjs

我已如下所示向我的羽毛应用添加了路由器

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": {}
}

我该如何解决?谢谢您。

1 个答案:

答案 0 :(得分:-1)

我认为您的代码应为:

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