From da19666b65f83b1ab796ceafe0b522dd4d03329e Mon Sep 17 00:00:00 2001 From: Edward Olstrom Date: Wed, 7 Dec 2022 14:39:12 -0500 Subject: [PATCH 1/5] started work --- lib/script.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/script.js b/lib/script.js index e69de29..7003743 100644 --- a/lib/script.js +++ b/lib/script.js @@ -0,0 +1,5 @@ +const url = "https://thecatapi.com/"; +const button = document.querySelector("randomButton"); + + + From 06769cef683336dfe55e18b9295e7255030693cc Mon Sep 17 00:00:00 2001 From: Edward Olstrom Date: Wed, 7 Dec 2022 14:47:29 -0500 Subject: [PATCH 2/5] added the event listener --- lib/script.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/script.js b/lib/script.js index 7003743..42359d6 100644 --- a/lib/script.js +++ b/lib/script.js @@ -1,5 +1,10 @@ -const url = "https://thecatapi.com/"; -const button = document.querySelector("randomButton"); +url = "https://thecatapi.com/"; + +const button = document.querySelector(".randomButton"); + +const catImage = document.querySelector('.img') + +buttonforCat.addEventListener('click', theClick) From 9c6780b5e42a38cdfff1145f8b531ee15c7c4c52 Mon Sep 17 00:00:00 2001 From: Edward Olstrom Date: Wed, 7 Dec 2022 18:09:06 -0500 Subject: [PATCH 3/5] Part 1 --- lib/script.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/script.js b/lib/script.js index 42359d6..47de7f9 100644 --- a/lib/script.js +++ b/lib/script.js @@ -1,10 +1,18 @@ -url = "https://thecatapi.com/"; +const url = "https://api.thecatapi.com/v1/images/search"; -const button = document.querySelector(".randomButton"); +const buttonForCat = document.querySelector(".randomButton"); const catImage = document.querySelector('.img') -buttonforCat.addEventListener('click', theClick) +buttonForCat.addEventListener('click', theClick) +function theClick() { + fetch(url) + .then((res) => res.json()) + .then((data) => { + console.log(data); + }) + .catch((err) => console.log("oops something went wrong", err)); +} From 48cd3282612dcba7ea135e7e9dcc2ca31bf14b74 Mon Sep 17 00:00:00 2001 From: Edward Olstrom Date: Wed, 7 Dec 2022 18:24:03 -0500 Subject: [PATCH 4/5] made edits to 1 --- lib/script.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/script.js b/lib/script.js index 47de7f9..3540d25 100644 --- a/lib/script.js +++ b/lib/script.js @@ -11,8 +11,7 @@ function theClick() { fetch(url) .then((res) => res.json()) .then((data) => { - console.log(data); + console.log(data[0]); }) - .catch((err) => console.log("oops something went wrong", err)); -} - + .catch((err) => console.log("oops something went wrong")); +} \ No newline at end of file From 914f21eb766b8b71dd6e3d1450d2d9bcdfe68b73 Mon Sep 17 00:00:00 2001 From: Edward Olstrom Date: Wed, 7 Dec 2022 18:29:44 -0500 Subject: [PATCH 5/5] Part 2 complete --- lib/script.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/script.js b/lib/script.js index 3540d25..007c6a9 100644 --- a/lib/script.js +++ b/lib/script.js @@ -2,7 +2,7 @@ const url = "https://api.thecatapi.com/v1/images/search"; const buttonForCat = document.querySelector(".randomButton"); -const catImage = document.querySelector('.img') +const catImage = document.querySelector('.randomCat') buttonForCat.addEventListener('click', theClick) @@ -11,7 +11,8 @@ function theClick() { fetch(url) .then((res) => res.json()) .then((data) => { - console.log(data[0]); + // console.log(data[0]); + catImage.innerHTML = `` }) .catch((err) => console.log("oops something went wrong")); -} \ No newline at end of file +}