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. However, we can maintain states using cookies and sessions on the client and the server side.

Plain JavaScript is applicable on the client or front-end side. However, developing the back-end logic in JavaScript and serving it as an endpoint requires creating a server. 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 see if it is.

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 as part of the module.

  • STATUS_CODES: This property lists all the status codes along with their descriptions, which are usually sent by the back-end servers to inform the status of the operation to the frontend or the client side.

Let’s now see them in action.

Get hands-on with 1400+ tech skills courses.