diff --git a/fetch/programmer-humour/index.html b/fetch/programmer-humour/index.html new file mode 100644 index 00000000..8c0660f8 --- /dev/null +++ b/fetch/programmer-humour/index.html @@ -0,0 +1,17 @@ + + + + + + + fetch data + + + + + + + + + + diff --git a/fetch/programmer-humour/script.js b/fetch/programmer-humour/script.js new file mode 100644 index 00000000..341b0ae4 --- /dev/null +++ b/fetch/programmer-humour/script.js @@ -0,0 +1,9 @@ +const url = "https://xkcd.now.sh/?comic=latest"; +const image = document.getElementById("image"); + +fetch(url) + .then((response) => response.json()) + .then((data) => image.src = data.img) + .catch((error) => { + console.log(error) + }); \ No newline at end of file diff --git a/fetch/programmer-humour/style.css b/fetch/programmer-humour/style.css new file mode 100644 index 00000000..e69de29b