I am using express.js and I am trying to fetch the request parameter using the following code.
app.configure(function () {
app.use(express.static(__dirname + '/public'));
});
app.get('/', function (req, res) {
console.log(req.params[0]);
console.log(req.params.id);
res.render('/public/index.html');
});
My url looks like this.
http://localhost:8080/?id=34.
I am not getting the request parameter. I tried all possibilities.
You need to reference req.query
req.params is for params embedded in the URL path.