Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ <h1>Random Cat API</h1>
<li>14: Sinks</li>
<li>15: Clothes</li>
</ul>
</div>
<div class="categoryCat"><img src="" class="categoryCatImage"></div>
</main>
<script src="script.js"></script>
Expand Down
28 changes: 28 additions & 0 deletions lib/script.js
Original file line number Diff line number Diff line change
@@ -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, ) {


// }