Menu

1 / 2

URL Parameters vs Query Strings in Express.js

DEV Community·Kunal·6 months ago
#GiqbuggW
Reading 0:00
15s threshold

Have you notice something like this in your url. It sometimes look like this 👇

https : //x.com/Kunalmadoliya

Enter fullscreen mode

Exit fullscreen mode

and sometimes like this 👇

https : //www.x.com/in/kunal-madoliya-0378133b4/?skipRedirect=true

Enter fullscreen mode

Exit fullscreen mode

Technically there are no difference in both. What is the advantage of one is disadvantage for the other

In this blog topic to cover :

What URL parameters are

What query parameters are

Differences between them

When to use params vs query

URL / Path parameters

We use URL parameter to access a specific resource on the server. For example if you want to find a user by ID.

We can simply implement this simple code with a URL parameter

app . get ( " /:username " , ( req , res ) => { res . send ( req . params .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.