Skip to content

Global fetch added in Node v18

Last updated on June 13, 2022

Starting from Node.js v18 the fetch API is available on the global scope by default. So we don’t have to install the node-fetch or other packages to make HTTP requests. The new global fetch is based on the undici package.

Example:

const res = await fetch('https://gorest.co.in/public/v2/users');
if (res.ok) {
  const data = await res.json();
  console.log(data);
}
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments