HTTP Module in Node.js
Get familiarized with the basic functions provided by the HTTP module in Node.js.
While dealing with simple to very complex web applications, back-end servers usually serve web pages and provide functionality to a website. Before moving on, let’s first understand HTTP.
What is HTTP?
HTTP (Hypertext Transfer Protocol) is a stateless protocol commonly used in the World Wide Web for data communication. HTTP uses a client-server model, where a client (usually a web browser or the one creating a request to the server) communicates to the server, and the server in response provides the requested data. The data can be of multiple forms, like HTML pages, images, videos, etc. Since HTTP is a stateless protocol, it means that each request is independent of all the other requests made by the client, and the server doesn’t store any information about the previous requests. We can, however, maintain states by using cookies and sessions to store the data on the client as well as the server side.
Plain JavaScript is applicable on the client or front-end side. But developing the back-end logic in JavaScript and serving it as an endpoint requires a server to be created. In the later lessons, we’ll explore how to create complex web applications using Express.js, but for now, we’ll explore one of the built-in modules in Node.js to create an HTTP server that can serve our web application.
The HTTP module in Node.js is one of the core modules available with Node, and we don’t need to install any other dependencies to use this module. Let’s now explore it.
Properties of the HTTP module
Let’s start by exploring a few of the properties of the HTTP module as given below:
METHODS
: This property lists all the methods available ...
Get hands-on with 1400+ tech skills courses.