DEV Community

Cover image for Day 22 – Route Parameters - Learning Node JS In 30 Days [Mini series]
Muhammad Ali (Nerdjfpb)
Muhammad Ali (Nerdjfpb)

Posted on • Originally published at blog.nerdjfpb.com

Day 22 – Route Parameters - Learning Node JS In 30 Days [Mini series]

Hey Everyone! How you are going on this vacation. Sorry to ruin a bit, but I'm back with the day 22.

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

Alt Text

See the result on the browser

Alt Text

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.

Alt Text

Now you know about using params, so you can create the profile page right ?

You can see the graphical version here

Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin !

You can read the old posts from this series (below)

Top comments (0)