How to parse variables in querystring using Express?
It's not a good idea to use a query string inside a route.
In Express logic you need create a route for "/stuff". The query string will be available in req.query
.
You can declare your route directly with /stuff
, then query parameters are accessible through req.query
, which is a JSON object.Here's your example:
app.get("/stuff", function(req, res) { var a = req.query.a; ...});
In your case, req.query
is equal to:
{ a: 'a', b: 'b', c: 'c' }
In Express' documentation (either 4.x and 3.x) you can find additional examples:Express - req.query.