The function passed into the http.createServer() has a req argument that represents the request from the client, as an object (http.IncomingMessage object).

This object has a property called “url” which holds the part of the url that comes after the domain name:

Save the code above in a file called “demo_http_url.js” and initiate the file:

If you have followed the same steps on your computer, you should see two different results when opening these two addresses:

http://localhost:8080/summer

http://localhost:8080/winter

Split the Query String

There are built-in modules to easily split the query string into readable parts, such as the URL module.

Save the code above in a file called “demo_querystring.js” and initiate the file:

The address:

http://localhost:8080/?year=2017&month=July

You can watch me here doing actual video tutorial with regards node.js here Learning How Node.JS Work AWS.