How to I get the GET (query string) variables in Express.js on Node.js?

Answer

First equation to get the variable string (value.query.id) so
var express = require('express');
var app = express();

app.get('/', function(req, res){
res.send('id: ' + req.query.id);
});

app.listen(3000);

 

otherwise we can get another
equation
var url = require('url');
var url_parts = url.parse(request.url, true);
var query = url_parts.query;

 

All node.js Questions

Ask your interview questions on node-js

Write Your comment or Questions if you want the answers on node-js from node-js Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---