Open In App
Related Articles

Node.js Request Module

Like Article
Save Article
Report issue

The request module is used to make HTTP calls. It is the simplest way of making HTTP calls in node.js using this request module. It follows redirects by default. 

Note: As of Feb 11th, 2020, the request is fully deprecated.

Feature of Request module:

  • It is easy to get started and easy to use.
  • It is a widely used and popular module for making HTTP calls.

Installation of request module:

 You can visit the link Install Request module. You can install this package by using this command.

npm install request

After installing the request module you can check your request version in the command prompt using the command.

npm version request

After that, you can create a folder and add a file for example index.js, To run this file you need to run the following command.

node index.js

The project structure will look like this: 

project structure




const request = require('request')
// Request URL
request(url, (error, response, body) => {
    // Printing the error if occurred
    if (error) console.log(error)
    // Printing status code
    // Printing body


Steps to run the program:

Make sure you have to install express and request modules using the following commands:

npm install request
npm install express

Run the index.js file using the below command:

node index.js

Output of above command

So this is how you can use the request module for making HTTP calls. It is very simple and easy to use.

Last Updated : 06 Apr, 2023
Like Article
Save Article
Share your thoughts in the comments
Similar Reads