Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

Global fetch added in Node v18

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);
}

Leave a Reply