Is there a difference between obtaining QUERY_STRING arguments via req.query[myParam] and req.params.myParam? If so, when should I use which?
Thanks.
Given this route
app.get('/hi/:param1', function(req,res){} );
and given this URL
http://www.google.com/hi/there?qs1=you&qs2=tube
You will have:
req.query
{
qs1: 'you',
qs2: 'tube'
}
req.params
{
param1: 'there'
}
req.params contains route parameters (in the path portion of the URL), and req.query contains the URL query parameters (after the ? in the URL).
See docs here.
Use req.param(name) to look up a parameter in both places, as well as req.body.