I have this route, /test
which I called but somehow it is triggering /:async
route as well when next() is called in /test
route's finally?
router.post('/test/:value?'async (req, res: express.Response, next: express.NextFunction) => {|
try{
//code
}catch(err){
//log error
}finally{
next();
}
})
router.post('/:id?'async (req, res: express.Response, next: express.NextFunction) => {
try{
//code
}catch(err){
//log error
}finally{
next();
}
})
I have this finalResponseHandler
middleware in server.ts file which is supposed to be called on next().
app.use(finalResponseHandler);
If I remove /:id?
route finalResponseHandler
middleware is called perfectly.
Why is this /:id route is getting called instead of finalResponseHandler middleware?
How do I correct this to not call /:id
route when calling '/test' route.
Any help is appreciated.