New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a clarification on router.param() usage. #5586
Comments
Hi @kisshore04, can you post more clear code examples? Ideally a single file/code block which illustrates your setup in its entirety? These partial lines do not help anyone answer your question. If it turns out this is a bug or in need of better docs or something I will leave this open awaiting more information, but we do not provide technical support so if that is what you are looking for you might have better luck on StackOverflow or Reddit. |
@kisshore04 have you tried router.param(‘department_id’)? Without the colon. https://expressjs.com/en/4x/api.html |
yeah i have always used router.param('department_id'); without the colon. I mistyped it in here. |
I apologize for the confusion in my previous message. Here is the revised version of the issue. I'm encountering an issue with the Here's the relevant code from
And from
Interestingly, in my department router where I have a similar setup, the middleware is executing successfully. The route to this is:
I've used the Any help on why |
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.
The text was updated successfully, but these errors were encountered: