Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCeil-Ian Maralit
Front End Web Development Techdegree Graduate 19,434 PointsRequest object params property
How did the value for the route parameter from the URL is stored in the request object params? Thank you!
1 Answer
Marco Cornejo
3,412 Pointsreq.params is an object containing properties mapped to Route parameters, in other words, the Route parameters are simply keys being declared, and req.params assign a value to them.
Say we want to display card with id 6, the composition is as follows
//Route path: /card/:id
//Request URL: http://localhost:3000/cards/6
//req.params: { "id": "6" }
Note that req.params can store multiple key:values, which is how most search engines apply filters or redeem/referral urls work, for further details check the Documentation: https://expressjs.com/en/api.html#req.params
I hope I answered your question, cheers!
Ceil-Ian Maralit
Front End Web Development Techdegree Graduate 19,434 PointsCeil-Ian Maralit
Front End Web Development Techdegree Graduate 19,434 PointsYes, yes, thank you so much! Totally helped! Cheers!