I have the following code in my server.js for route middleware:
app.use('/users', require('./routes/user.routes'));
app.use((req, res) => res.status(404).json({code: 404, message: 'HTTP 404 Not Found'}));
And following is my user.routes.js code
router.get('/admin/:id', (req, res) => {
return userController.findUserById(req, res);
});
It works fine as long as I give : localhost:8080/users/admin/123 But when I give the url without id localhost:8080/users/admin/
it sends me this message : {"code":404,"message":"HTTP 404 Not Found"}
In my opinion it should direct me to proper route. Am I missing something?