-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
31 lines (31 loc) · 933 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const catsAPI = "https://api.thecatapi.com/v1/breeds";
let row = document.querySelector(".row");
// Path: script.js
const getCatData = async () => {
const response = await fetch(catsAPI);
const data = await response.json();
return data;
};
getCatData().then((data) => {
data.forEach((elem) => {
// elem.description = elem.description.substring(0, 100);
row.innerHTML += `
<div class="col-4">
<div class="card" style="width: 18rem">
<img class="card-img-top" src="${
elem.image.url
}" alt="Card image cap" />
<div class="card-body">
<h5 class="card-title">${elem.name}</h5>
<p class="card-text">
${elem.description.substring(0, 200)}
</p>
<a href="${
elem.wikipedia_url
}" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
`;
});
});