I am starting a series on node js. Actually I’m not super skilled with node js. So I thought let’s start from zero again and help others with me to learn about it. I saw the ‘the net ninja’ tutorials and took the syllabus from there and make a fusion of my own. I want to help you with my journey, let’s ride together into node js for 30 days…
Day 22 — Route Parameters— Learning Node JS In 30 Days [Mini series]
A full series to learn the basics easily of node js
Up until now we never passed any id with our route. What if we need to go to a specific profile ?
Like — profile/10
How we can load different using those id ?
We can get what user request after profile, how we can get it ? In this case they request for the 10 right ?
To catch the 10 we need to make a specific route like ‘/profile/:id’ this id will catch what request send after profile. So how to catch it ?
Just use req.params.id
this will give us the id
See the result on the browser
So we get the details using req.params right ? So what is req.params
? we can easily console log it and what we got ?
An object contain the extra parameters we send with the url.
Now you know about using params, so you can create the profile page right ?
Originally it published on nerdjfpb blog and graphical version on instagram. you can connect with me in twitter, linkedin or instagram