2016-11-19 7 views
0

のparamsが、私はそうのように一緒にネストされた2台のルータを持っていると仮定しなさい:親ルータ

var appRouter = express.Router(); 
var childRouter = express.Router(); 

appRouter.use('/:parentId/childpath', childRouter); 
childRouter.get('/:childId', (req, res, next) => { 
    console.log(req.params); //only childId 
    // How do I get parentId ? 
}); 

は、サブルータハンドラでparentIdを取得する方法はありますか?

答えて

2

私はxDでいることを見逃してましたか

express.Router({ mergeParams: true }) 
+0

と子ルータを作成します。 – rocketspacer

関連する問題