Node.js URL Module

      No Comments on Node.js URL Module

URL module is included by defualt in Node Js. So, when Node Js is installed , url module is installed by default.

Node Js can be included in code as below :

var url = require(“url”);

url module in NodeJs can be used to parse the url and get the query parameters.

Let’s take an example to illustrate this:


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

   var q = url.parse(request.url,true);
   var firstName = q.query.firstName;
   var lastName = q.query.lastName;

   response.write("FirstName = "+firstName + " ,LastName = "+lastName);


Run this code as node demourlmodule.js

And then hit the following url in the browser

Leave a Reply