2024-02-02
3102
#node
Geshan Manandhar
33837
Feb 2, 2024 â‹… 11 min read

5 ways to make HTTP requests in Node.js

Geshan Manandhar Geshan is a seasoned software engineer with more than a decade of software engineering experience. He has a keen interest in REST architecture, microservices, and cloud computing. He also blogs at geshan.com.np.

Recent posts:

Exploring Hurl An Alternative To Postman

Exploring Hurl, a command line alternative to Postman

Hurl is an excellent Postman alternative that improves the DX of working with APIs through the command line.

Nwani Victory
May 20, 2024 â‹… 8 min read
How To Integrate WunderGraph With Your Frontend Application

How to integrate WunderGraph with your frontend application

Unify and simplify APIs using WunderGraph to integrate REST, GraphQL, and databases in a single endpoint.

Boemo Mmopelwa
May 17, 2024 â‹… 5 min read
Understanding The Latest Webkit Features In Safari 17.4

Understanding the latest Webkit features in Safari 17.4

The Safari 17.4 update brought in many modern features and bug fixes. Explore the major development-specific updates you should be aware of.

Rahul Chhodde
May 16, 2024 â‹… 10 min read
Using Webrtc To Implement Peer To Peer Video Streaming In A Node Js Project

Using WebRTC to implement P2P video streaming

Explore one of WebRTC’s major use cases in this step-by-step tutorial: live peer-to-peer audio and video streaming between systems.

Oduah Chigozie
May 16, 2024 â‹… 18 min read
View all posts

6 Replies to "5 ways to make HTTP requests in Node.js"

  1. The one with fetch throws this error:
    Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /xxx/node_modules/node-fetch/src/index.js
    require() of ES modules is not supported.
    require() of /xxx/node_modules/node-fetch/src/index.js from /xxx/index.js is an ES module file as it is a .js file whose nearest parent package.json contains “type”: “module” which defines all .js files in that package scope as ES modules.
    Instead rename /xx/node_modules/node-fetch/src/index.js to end in .cjs, change the requiring code to use import(), or remove “type”: “module” from /xxx/node_modules/node-fetch/package.json.

Leave a Reply