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!