Skip to content

Commit e03911d

Browse files
committed
programmer-hummour task completed
1 parent 3a422e9 commit e03911d

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

fetch/programmer-humour/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Programmer Humour</title>
7+
<link rel="stylesheet" href="style.css" />
8+
<script src="script.js" defer></script>
9+
</head>
10+
<body>
11+
<img id="comic" />
12+
</body>
13+
</html>

fetch/programmer-humour/script.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function getComic() {
2+
fetch("https://xkcd.vercel.app/?comic=latest")
3+
.then((response) => response.json())
4+
.then((data) => {
5+
console.log(data);
6+
7+
const img = document.getElementById("comic");
8+
img.src = data.img;
9+
})
10+
.catch((error) => {
11+
console.log("Error:", error);
12+
});
13+
}
14+
getComic();

fetch/programmer-humour/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
body {
2+
height: 100vh;
3+
display: flex;
4+
justify-content: center;
5+
align-items: center;
6+
background-color: rgb(58, 57, 55);
7+
}

0 commit comments

Comments
 (0)