简体   繁体   中英

how to add router/middleware to feathers app?

I have added a router to my feathers app as follows

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

app is running at http://localhost:3030/ when I send get request to http://localhost:3030/test from postman I get following error

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

how can I fix this? Thanks in anticipation.

I think your code should be :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM