Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

336
Views
JS ¿Por qué mi función asíncrona devuelve indefinida?

Estoy empezando a entender async/await pero aún no lo he descubierto. ¡Realmente espero que puedas ayudarme!

 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 */

La consola JS muestra: NO Promise 43000480694

¿Por qué está en ese orden y por qué la función devuelve indefinida? Debería ser: SÍ Promesa 43000480694

¡Muchas gracias por tu ayuda!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Para que una función devuelva algo, debe tener al menos la palabra clave de return .
  2. Para hacer referencia a una función, use test1 , para llamar a una función, use test1() . Los () son obligatorios.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!