From 474b4b4fbf78a9b0ba0c34bc15b02d0984d5b202 Mon Sep 17 00:00:00 2001 From: Ron Lanzilotta Date: Wed, 7 Dec 2022 13:46:53 -0500 Subject: [PATCH] Used API key, finished --- lib/index.html | 1 - lib/script.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/index.html b/lib/index.html index 0e97ce8..d32f536 100644 --- a/lib/index.html +++ b/lib/index.html @@ -31,7 +31,6 @@

Random Cat API

  • 14: Sinks
  • 15: Clothes
  • -
    diff --git a/lib/script.js b/lib/script.js index e69de29..306f30e 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_MWhL6d9uLe1SLmWjK7AELzKHa6cXS2aR1rX0GWNmWQFAai1IQo1eumVnhYG7RdHf' +} + +const catButton = document.querySelector(`.randomButton`); + +catButton.addEventListener('click', handleClick) +// const container = document. + +function handleClick() { +fetch(url, { header }) + .then((res) => res.json()) + .then((res) => { + let randImage = document.querySelector(".randomCatImage"); + randImage.src = res[0].url; + }); +} + + + +// function displayData(data){} + +// function displayCat(url, ) { + + +// } \ No newline at end of file