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

332
Vistas
JS Why does my async function return undefined?

I'm beginning to understand async / await but I haven't figured it out yet. I really hope you can help me!

async function test1() {
  const fetchPromise = await fetch("https://www.instagram.com/boarirkeerd/?__a=1", {})
  .then(response => response.json())
  .then(response => {
    console.log(response["graphql"]['user']['id']); /* returns 43000480694 */
    return response["graphql"]['user']['id']; /* returns undefined */
  });};

if (await test1 == "43000480694") {console.log("YES");}
else {console.log('NO');} /* returns NO */
test1(); /* undefined */

The JS console shows: NO Promise 43000480694

Why is it in that order and why does the function return undefined? It should be: YES Promise 43000480694

Thanks a lot for your help!

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

0

  1. For a function to return something, it must at least have the return keyword.
  2. To reference a function, use test1, to call a function, use test1(). The () are required.
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