// hasProjectPremission List this
hasProjectPremission = (req, res, next) => {
console.log(req.params); // {}
next();
}
router.use(apiBiz.hasProjectPremission);
router.post('/:projId/api/new', apiBiz.createApi);
When request to the create api, I can’t get req.params in hasProjectPremission
, it’s an empty object({})。
Actually middleware can get parameters from router, but it needs to know which one.
for example:
But IMO you should use router.param which will act like an middleware, executed right before route is handled.