Skip to content Skip to sidebar Skip to footer

Express/node.js - How To Pass Route Parameters To Other Files?

Encountered a strange bug where if I have a route defined like so in routes/posts/index.js: router.use('/:id/edit', require('./edit')); Inside ./edit, I have the endpoint defined

Solution 1:

You can merge in parent router parameters by passing {mergeParams: true} to express.Router().


Post a Comment for "Express/node.js - How To Pass Route Parameters To Other Files?"