I have a method 'getAssetByIdAsync(assetId)'
export const getAssetByIdAsync = (assetId) => {
const asset = assets.find((a) => a.id === assetId);
if (!asset) {
throw new Error("Asset not found" + assetId);
}
return new Promise((resolve) => setTimeout(() => resolve(asset), 500));
};
this method returns a Promise.
I have created a method 'renderMasterThumb(masterAssetId)'
const renderMasterThumb = async (masterAssetId) => {
const masterAsset = await getAssetByIdAsync(masterAssetId);
const path = masterAsset.path;
return path;
};
I was hoping that this method would return the .path property of masterAsset, but it turns out that the method return a Promise object.
If I print through a console.log(path), I get the right value: 'bart.jpg'
How can I make the renderMasterThumb method return an image path instead of a Promise Object.
thanks for your help,
Anthony