• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: req.params is throwing “undefined” in Router file

Resolved: req.params is throwing “undefined” in Router file

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I am doing a practise project in Node/Express.
My server.js looks like this:
now in my Route file routes/Envelopes_name I have this:
after sending request localhost:3000/envelopes/groceries?name=taxes it should change the name of the envelope from “groceries” to “taxes”. For some reason req.params.name is “undefined” and I have error “TypeError: Cannot set properties of undefined (setting ‘name’)”. When I had it all in one file, without routers, it worked perfectly. Any ideas?

Answer:

I think you need to add { mergeParams: true } to make the params available, because you use another router file then where you define the route.
See Express docs

If you have better answer, please add a comment about this, thank you!

express javascript node.js
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How can I copy files using the ansible.builtin.copy module and avoid conflicting file names?

26/03/2023

Resolved: Reshape tensors of unknown shape with tf.function

26/03/2023

Resolved: Use Svelte Component as Slot

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.