Last Updated: February 25, 2016
·
4.624K
· pmaoui

How to fetch GET, POST and URL based params with NodeJS

I always forget that, here a brief reminder.

To fetch GET params

app.get("/page",function(req,res) {
    var param = req.query["param"];
});

To fetch POST params

app.use(express.bodyParser());

app.get("/page",function(req,res) {
    var param = req.body["param"];
});

To fetch URL Route params :

app.get("/page_:param/",function(req,res) {
    var param = req.params.param
});