Skip to content

Commit 9bda503

Browse files
committed
fix: add null check for container and correct fallback image variable name in renderComic
1 parent c13ee12 commit 9bda503

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fetch/programmer-humour/script.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,19 @@ const fetchData = async () => {
3131
};
3232

3333
const renderComic = async () => {
34+
if (!container) {
35+
console.error("Comic container not found in DOM");
36+
return;
37+
}
38+
3439
const data = await fetchData();
3540
console.log(data);
3641
if (data && data.img) {
3742
imgEl.src = data.img;
3843
imgEl.alt = data.alt || data.title || "Programmer humour comic";
3944
} else {
4045
console.error("Image data not received");
41-
imgEl.src = fallbackImage;
46+
imgEl.src = fallbackImg;
4247
imgEl.alt = "No image available";
4348
}
4449
};

0 commit comments

Comments
 (0)