From 186841c1bef49b5119ed20be7571ef11bb3465d7 Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 7 Dec 2022 15:57:20 -0500 Subject: [PATCH 1/2] Part 1 --- lib/script.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/script.js b/lib/script.js index e69de29..95c901d 100644 --- a/lib/script.js +++ b/lib/script.js @@ -0,0 +1,14 @@ +const url = "https://api.thecatapi.com/v1/images/search" + +const button = document.querySelector(".randomButton") + +button.addEventListener("click", handleClick) + +function handleClick() { +fetch(url) + .then((res) => res.json()) + .then((data) => { + console.log(data); + }) + .catch((err) => console.log("oops something went wrong", err)); +} From de7968e79e48af80562690e165d95b2a05cc902d Mon Sep 17 00:00:00 2001 From: ksooooza Date: Wed, 7 Dec 2022 16:58:25 -0500 Subject: [PATCH 2/2] Part 2 --- lib/script.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/script.js b/lib/script.js index 95c901d..ffda082 100644 --- a/lib/script.js +++ b/lib/script.js @@ -8,7 +8,8 @@ function handleClick() { fetch(url) .then((res) => res.json()) .then((data) => { - console.log(data); + //console.log(data[0].url); + document.querySelector(".randomCat").innerHTML = `` }) .catch((err) => console.log("oops something went wrong", err)); -} +} \ No newline at end of file