Express Router undefined params with router.use when split across files

后端 未结 1 1306
灰色年华
灰色年华 2020-12-09 14:34

I\'m not sure if this is a bug in Express, or if I\'m just doing something wrong (probably the latter), but I\'m finding that req.params is only retaining parameters in the

相关标签:
1条回答
  • 2020-12-09 15:38

    When you create your Router in File 2, you need to tell it to inherit params from parents.

    var router = express.Router({mergeParams: true});
    

    http://expressjs.com/api.html#router

    0 讨论(0)
提交回复
热议问题