Posts

Showing posts from June 21, 2018

Use of req.query, req.params and req.body in NODE JS

Image
I am writing this article for beginners. Because, at the time of learning node js, this is very confusing where and how we need to use req.query, req.params and req.body . I am going to explain these three req method below. 1.        Req.query 2.        Req.params 3.        Req.body Req.query: When request is coming in key and value pair, for example, if your URL looks like below URL http://localhost:3000/search?name=xyz&age=16 In the above URL, you can see that request is coming in key and value pair . First key is name and value is xyz, second key is age and value is 16. In the node js programing, if you want to parse this url then use req.query. Below is the code snippet to parse this URL. router.get('/search', function(req, res, next) {   var name = req.query.name;   console.log(`Name :  ${name}`)   var age = req.query.age;   ...

Recent Post

Recent Posts Widget