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

330
Views
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 answers
Answer question

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 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!