The Fetch API is finally stable in Node.js

Explanation:
The Fetch API is provided as a high-level function, which means you don’t have to do any import/require before using it in your Node.js applications.
In its most basic version, it takes a URL, sends a GET request to that URL (if the request method is not defined), and produces a promise that resolves the response. Here’s an example below:
Code:
fetch("http://example.com/api/endpoint", { method: "POST", // Specify request method headers: { // Customize request header here "Content-Type": "application/json", // . . . }, body: JSON.stringify({ foo: "bar", bar: "foo", }), // . . . }) .then((res) => res.json()) .then((data) => { console.log("Response data:", data); }) .catch((err) => { console.log("Unable to fetch -", err); });
Comments :
Node.js is my favorite! It's amazing, and I'm really enjoying working with Node.js, Express.js, and MongoDB.