Learning how to make HTTP requests can feel overwhelming as there are dozens of libraries available, with each solution claiming to be more efficient than the last. Some libraries offer cross-platform support, while others focus on bundle size or developer experience. In this post, we’ll explore five of the most popular ways to achieve this core functionality in Node.js.

The code demonstrations will use the Lord of the Rings themed API,  one API to rule them all, for all interactions-simply because I accidentally binge-watched the entirety of this excellent series last weekend.


Ensure you have  npm and Node.js installed on your machine, and you’re good to go!

Prefer to jump ahead? This post will cover:

  • HTTP (The Standard Library)
  • SuperAgent
  • Axios
  • Node Fetch
  • Got

HTTP (The Standard Library)

The standard library comes equipped with the default http module. This module can be used to make an HTTP request without needing to add bulk with external packages. However, as the module is low-level, it isn’t the most developer-friendly. Additionally, you would need to use  asynchronous streams for chunking data as the async/await feature for HTTP requests can’t be used with this library. The response data would then need to be parsed manually.

#superagent #nodejs #http-request #axios #node-fetch

5 Ways To Make HTTP Requests In Node.js - 2020 Edition
4.60 GEEK