requestjs query params code example

Example 1: get query parameters in node.js

var express = require('express');
var app = express();

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

app.listen(3000);

Example 2: express get raw query

const url = require('url');
const express = require('express');

const app = express();
app.use((req, res, next) => {
  const query = url.parse(req.url).query;
  // Do something...
});

const port = 3000;
app.listen(port, console.log(`Listening on port ${port}.`));