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: 1 addition & 0 deletions lib/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!DOCTYPE html>
<html>
<head>
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_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;
});
}