Node.js express middleware is running on parse.com.
For the following request: http://gopaces.com/echo/test123?getParam1=AAA handled by the following code in app.js:
app.get('/echo/:reqParam', function(req, res) {
console.log("reqParam " + req.params.reqParam);
console.log("getParam1 " + req.params.getParam1);
});
The following is printed
E2014-07-30T09:20:41.511Z]v92 Ran custom endpoint with:
Input:{"method":"GET","url":"/echo/test123?getParam1=AAA","headers":{"accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","accept-encoding":"gzip, deflate","accept-language":"en-us","host":"gopaces.com","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/538.46 (KHTML, like Gecko) Version/8.0 Safari/538.46","version":"HTTP/1.1","x-forwarded-proto":"http"}}
Result: success/error was not called
I2014-07-30T09:20:41.617Z]reqParam test123
I2014-07-30T09:20:41.831Z]getParam1 undefined
Where as I would expect to see
I2014-07-30T09:20:41.617Z]reqParam test123
I2014-07-30T09:20:41.831Z]getParam1 AAA
What am I doing wrong?
Your named parameters relate to the path of the URL, not the query string variables. Your query string variables will not be accessible in the params object, but instead in the req.query object.
For reference completeness
For the given request
curl -X PUT -d 'viaBody=bodyValue' 'http://gopaces.com/echo/parameterValue?viaQuery=queryValue'
This code
app.put('/echo/:viaParameter', function(req, res) {
console.log("viaParameter " + req.params.viaParameter);
console.log("viaQuery " + req.query.viaQuery);
console.log("viaBody " + req.body.viaBody);
});
Will dump the values
I2014-07-30T11:21:39.336Z]viaQuery queryValue
I2014-07-30T11:21:39.337Z]viaBody bodyValue
I2014-07-30T11:21:39.338Z]viaParameter parameterValue