All JavaScript functions return something. However, if your function is async
it’s
going to return a Promise
, so you can use the keyword await
to get the value that
the promise resolves to.
So you have an async
function apiCall
that takes some time to resolve.
You call it, try to log the result and get some Promise { <pending> }
.
const result = apiCall(); // calling an async function
console.log(result); // Promise { <pending> }
By adding the keyword await
, you’re waiting for the async
function to return the
result.
const result = apiCall();
console.log(await result);