Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

301
Vistas
Why is node fetch not working (node-fetch) in javascript

I'm trying to fetch data from a URL with fetch but it doesn't work. I imported node-fetch module by typing:

const fetch = require("node-fetch");

And here's where I use it:

async function getUrl(url) {
    let d = await fetch(url);
    let j = d.json();
    return j;
}

getUrl(myURL);

I also have the 'npm install node-fetch' to the terminal and it says there's no such file or directory.

Do you know where I am having the issue?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Once fetch is imported this works (in browsers fetch is built-in):

async function getUrl(url) {
    let d = await fetch(url);
    let j = await d.json();
    return j;
}

// example JSON API
const myURL = 'https://reqres.in/api/users';

// IIFE needed for demonstration purposes
(async function(){
  const data = await getUrl(myURL);
  console.log(data);
})()

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda