In this notebook I have a function which returns an object by means of a fetch. If I merely run the function it successfully returns the object.
fetch
However, if I try to access that property, it returns as undefined. Can someone explain what’s going on there?
The function return the fetch Promise, which will resolve asynchronously when the resource is actually downloaded and processed. Add await before the promise and you will get its resolved value.
await
const cn = await colorName(hex);