How to get a URL parameter in Express?

Express 4.x To get a URL parameter’s value, use req.params app.get(‘/p/:tagId’, function(req, res) { res.send(“tagId is set to ” + req.params.tagId); }); // GET /p/5 // tagId is set to 5 If you want to get a query parameter ?tagId=5, then use req.query app.get(‘/p’, function(req, res) { res.send(“tagId is set to ” + req.query.tagId); }); … Read more

Get the values from the “GET” parameters (JavaScript) [duplicate]

JavaScript itself has nothing built in for handling query string parameters. Code running in a (modern) browser can use the URL object (a Web API). URL is also implemented by Node.js: // You can get url_string from window.location.href if you want to work with // the URL of the current page var url_string = “http://www.example.com/t.html?a=1&b=3&c=m2-m3-m4-m5”; … Read more