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
});Written by pmaoui
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Express
Authors
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
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#