I want to create a async method that returns an image path like this:
const renderMasterThumb = async (masterAssetId) => {
const masterAsset = await getAssetByIdAsync(masterAssetId);
const path = masterAsset.path;
return path;
};
then I call the method like this:
<img
src={`images/${(async () => {
await getAssetByIdAsync(collection.masterAssetId);
})()}`}
alt="master thumb"
/>
However instead of the image path I get a Promise object:
<img src="images/[object Promise]" alt="master thumb">
Does someone know how I can output the value (eg 'bart.jpg') from calling an async method?
thanks for your help,
Anthony
asyncinfront of a function simply means: this function returns an promise. so you need to handle it like an promise