0
getPhotoStatus();
async function getPhotoStatus () {
    let res = await fetchPhoto('/photos/19062657811.png');
    console.log(res);
}
async function fetchPhoto(uri) {
    const status = fetch(uri).then(response => response.status);
    return status;
} 

I have this code here, it works fine but removing getPhotoStatus() and awaiting the fetch function directly in fetchPhoto() returns a Promise, is there another way to do this instead of making double functions basically to get the value of a Promise directly from the outer scope?

cybercivizen
  • 79
  • 1
  • 7
  • `await` is basically just syntactic sugar for using `.then()`. – Barmar Nov 16 '21 at 18:07
  • "*awaiting the fetch function directly in fetchPhoto() returns a Promise*" - hm, `await` *never* returns a promise, so I don't understand what you did. Can you please [edit] your question to also include the non-working code? – Bergi Nov 16 '21 at 21:12

0 Answers0