diff --git a/fetch/programmer-humour/index.html b/fetch/programmer-humour/index.html new file mode 100644 index 0000000..ac7c3cf --- /dev/null +++ b/fetch/programmer-humour/index.html @@ -0,0 +1,16 @@ + + + + + + Programming Humour + + + + +
+

+ +
+ + \ No newline at end of file diff --git a/fetch/programmer-humour/script.js b/fetch/programmer-humour/script.js new file mode 100644 index 0000000..ca30e0f --- /dev/null +++ b/fetch/programmer-humour/script.js @@ -0,0 +1,23 @@ +const apiUrl = 'https://xkcd.now.sh/?comic=latest'; + +async function programmerHumour () { + const response = await fetch(apiUrl); + let data = await response.json(); + + + const container = document.getElementById('container'); + + const h1 = document.getElementById('title'); + h1.textContent = data.title; + + const image = document.getElementById('image'); + image.src = data.img; + + container.appendChild(h1); + container.appendChild(image); + console.log(data); +} + + + +programmerHumour(); \ No newline at end of file diff --git a/fetch/programmer-humour/styles.css b/fetch/programmer-humour/styles.css new file mode 100644 index 0000000..ff2fae1 --- /dev/null +++ b/fetch/programmer-humour/styles.css @@ -0,0 +1,22 @@ +* { + margin: 0; + padding: 0; + font-family: 'Poppins', sans-serif; + box-sizing: border-box; +} + +#container { + background: rgb(172, 170, 170); + width: 60%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 40px; + margin: 50px auto; + border-radius: 5px; +} + +h1 { + margin-bottom: 2rem; +} \ No newline at end of file