diff --git a/lib/index.html b/lib/index.html index 0e97ce8..5ed24e2 100644 --- a/lib/index.html +++ b/lib/index.html @@ -1,3 +1,4 @@ + diff --git a/lib/script.js b/lib/script.js index e69de29..1c77767 100644 --- a/lib/script.js +++ b/lib/script.js @@ -0,0 +1,28 @@ +const url= "https://api.thecatapi.com/v1/images/search" +let header = { + "x-api-key": + "live_c7NFwQNovYorkhRwoYbtV1ytRgM1c7I3KmWGi5ucgGsnk1aBvtmJfe4HDV36SJzd" +} +const catButton = document.querySelector(`.randomButton`); +catButton.addEventListener('click', handleClick) + + +function handleClick() { +fetch(url, {header}) + .then((res) => res.json()) + .then((res) => { + let randImage = document.querySelector(".randomCatImage"); + randImage.src = res[0].url; + }); +} + + + + + + + + + + +