nodejs catch get parameter code example

Example 1: node js http request get parameters

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

http.createServer(function (req, res) {
  const queryObject = url.parse(req.url,true).query;
  console.log(queryObject);

  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Feel free to add query parameters to the end of the url');
}).listen(8080);

Example 2: expressjs receive url parameter

URL Parameters
These are information that are passed through the URL like so:

http://example.com/api/users?id=4&token=sdfa3&geo=us