Node.js | Request Module

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.

Feature of Request module:

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

Installation of request module:

  1. You can visit the link Install Request module. You can install this package by using this command.
    npm install request
  2. After installing request module you can check your request version in command prompt using the command.
    npm version request
  3. 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

Filename: index.js





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:

  1. The project structure will look like this:
    project structure
  2. Make sure you have install express and request module using following commands:
    npm install request
    npm install express
  3. Run index.js file using 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.

My Personal Notes arrow_drop_up

To obtain a position of responsibility that utilizes my skills and keen to work in an environment where I can enrich my knowledge

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.