Last Updated: February 25, 2016
·
5.341K
· 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
});

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside