So i have a 404 handler and a router file:
404 handler:
app.all("*", (req, res, next) => {
res.status(404).json({
"status": "failed",
"message": "woops, page not found..."
})
})
Router:
orderRouter.route('/')
.post((req, res, next, optionalData) => {
res.status(200).json({
"status": "ok"
})
})
module.exports = orderRouter
As we can see, i add extra arguments in middleware, that is "optionalData".
When i access the route / method POST, i got 404 result.
But when i define that optionalData = undefined, it works. I got results "status": "ok".
(req, res, next, optionalData = undefined)
But why? what happen here..