Skip to content

Need a clarification on router.param() usage. #5586

@kisshore04

Description

@kisshore04

I was using router.param() method to run middleware in all the routes which has ':department_id'.
for example:
In my app, the route will be app.use('/department/:department_id/class',departmentRoutes);
In my departmentRoutes, child route will be router.get('/:id', ...controller);

I have use { mergeParams : true } to include all the params in the router to consider.. but when i use router.param(':department_id', ); the middleware gets skipped as it considers the ':department_id' as no parameter.

But the when we use router.param('id',); the middleware logic gets executed perfectly!!

kindly clear me of the doubt that, will the router.param() consider the params from the parent or app.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions