An app thatcan colect cats pictures from online.
Cat Collector App
Cat Collector App
<!DOCTYPE html>
<html>
<head>
<title>Cat Collector App</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h1>Cat Collector App</h1>
<button onclick="collectCats()">Collect Cats</button>
<br>
<div id="catImages"></div>
<script>
function collectCats() {
$.ajax({
url: "https://api.thecatapi.com/v1/images/search?limit=10",
type: "GET",
dataType: "json",
success: function (data) {
console.log(data);
var images = "";
for(var i=0; i<data.length; i++) {
images += "<img src='"+data[i].url+"' style='width:200px;margin:10px;'>";
}
$("#catImages").html(images);
},
error: function (error) {
console.log(error);
$("#catImages").html("Failed to collect cats. Please try again later.");
}
});
}
console.log("Why do cats always purr around mathematicians? Because they love to hear them cat-lit functions!");
</script>
</body>
</html>