Skip to content

Commit 59e51c7

Browse files
committed
refactor: 💡 removed unnecessary promise within async function
removed extra promise and added a try catch around the await
1 parent 304fcfc commit 59e51c7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

utils/generate_metadata.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,15 @@ const getImages = (_dir) => {
4444
};
4545

4646
const loadImgData = async (_imgObject) => {
47-
return new Promise(async (resolve) => {
47+
try {
4848
const image = await loadImage(`${_imgObject.path}`);
49-
resolve({ imgObject: _imgObject, loadedImage: image });
50-
});
49+
return {
50+
imgObject: _imgObject,
51+
loadedImage: image,
52+
};
53+
} catch (error) {
54+
console.error("Error loading image:", error);
55+
}
5156
};
5257

5358
const draw = (_imgObject) => {

0 commit comments

Comments
 (0)