Files
purplebored.pl/oldprojects/cat/script.js
2024-05-04 17:48:04 +02:00

13 lines
393 B
JavaScript

function getCat() {
fetch('https://api.thecatapi.com/v1/images/search')
.then(response => response.json())
.then(data => {
let catImg = document.getElementById('cat-img');
catImg.src = data[0].url;
catImg.width = 400;
catImg.height = 400;
})
.catch(error => {
console.error('Error fetching cat picture', error);
});
}