-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
Closed
Labels
Description
When i built auth app
My middlewares:
- protected (for check token)
- controllers (to validate body data and interact with services)
- exceptions (sent error status to client if internal error thrown)
when i use next(id) on protected middleware it throws and error and skip controllers.
It goes to exceptions middleware (skip the controllers). In my case i need pass id to the expected contollers but it gives error.
and work excatly as expected, when i change my code to
try{
const {id} = await verifyToken()
req.id = id
next()
}catch(error){
next(error)
}My question:
if i pass a parameter to next() interface, does it redirect to express internal error handler? even if i dont use try-catch statements