Skip to content

Commit

Permalink
Eliminated JavaScript errors when image is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
TyroneAEM committed May 28, 2024
1 parent 39b9343 commit 30dfb9e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions blocks/gmo-campaign-details/gmo-campaign-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ export default async function decorate(block) {
buildProductCard(program);
try {
const imageObject = await searchAsset(program.programName, program.campaignName);
insertImageIntoCampaignImg(block,imageObject);
document.getElementById('totalassets').textContent = imageObject.assetCount;
if (imageObject){
insertImageIntoCampaignImg(block,imageObject);
document.getElementById('totalassets').textContent = imageObject.assetCount;
}
} catch (error) {
console.error("Failed to load campaign image:", error);
}
Expand Down

0 comments on commit 30dfb9e

Please sign in to comment.