Here are 2 simple scenarios:
- Get
user
withid
and return - Get
user
withid
, do some other stuff, and then return
I want to implement scenario 2
as
router.post('/api/users/:id/someStuff', controller.getUser, controller.doStuff)
But scenario 1
should be implemented as
router.post('/api/users/:id/someStuff', controller.getUser)
Basically, controller.getUser
is both a middleware and an endpoint. How do I accomplish this? If I use res.son()
inside getUser
and later on reuse it inside doStuff
, then I get an error.
Aucun commentaire:
Enregistrer un commentaire