1

I have an endpoint: POST /:service/confirm. This is handled by

index.js

router.use("/:services", services);

services.js

router.post("/confirm", (req, res) => {
   console.log(req.params);
 });

I'm planning to get the params.services inside of services.js. But when I logged it, its empty. I'm assuming that req.params is focusing on the current path. Are there any workarounds for this?

jhnferraris
  • 1,361
  • 1
  • 12
  • 34

1 Answers1

3

You need set mergeParams option to true:

Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence.

stdob--
  • 28,222
  • 5
  • 58
  • 73