Shafayat Alam
Shafayat Alam

Reputation: 730

Number of parameters sent via URL in nodeJS

I need to find how many parameters sent in an URL.

How can I determine the number of parameters sent via URL in nodeJS?

Upvotes: 0

Views: 50

Answers (2)

Harshit Anand
Harshit Anand

Reputation: 702

If using express framework

req.params // can be used

See the documentation here

Upvotes: 2

Subburaj
Subburaj

Reputation: 5192

use req.query

if Your URL is like localhost:3000?param1=&param2=

var params = req.query;
van length = Object.keys(params).length;

the length is 2.

Upvotes: 1

Related Questions