Here are 2 simple scenarios:
- Get
userwithidand return - Get
userwithid, 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