Open In App
Related Articles

Node.js Request Module

Improve Article
Save Article
Like Article

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.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 06 Apr, 2023
Like Article
Save Article
Similar Reads
Complete Tutorials