-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
33 lines (28 loc) · 811 Bytes
/
scripts.js
File metadata and controls
33 lines (28 loc) · 811 Bytes
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
32
33
const catA = document.getElementById('cat-a');
const catB = document.getElementById('cat-b');
const catC = document.getElementById('cat-c');
const fetchCat = async (element) => {
const response = await fetch('https://cataas.com/cat/cute?width=300');
const blob = await response.blob();
element.src = URL.createObjectURL(blob);
};
const fetchCatThen = (element) => {
fetch('https://cataas.com/cat/cute?width=300')
.then((response) => response.blob())
.then((blob) => {
element.src = URL.createObjectURL(blob);
});
};
const asyncCats = () => {
// fetchCat(catA);
// fetchCat(catB);
// fetchCat(catC);
fetchCatThen(catA);
fetchCatThen(catB);
fetchCatThen(catC);
};
const syncCats = async () => {
await fetchCat(catA);
await fetchCat(catB);
await fetchCat(catC);
};