/
helloPaprika.html
42 lines (42 loc) · 1.44 KB
/
helloPaprika.html
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
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello Paprika</title>
<script>
async function goGetIt() {
try {
var trows = []; // instantiate
fetch('https://api.coinpaprika.com/v1/coins')
.then( response => response.json())
.then( coins => {
for (let i = 0; i < 20; ++i) {
const coin = coins[i];
trows.push(`<tr>
<td>${coin.name}</td>
<td>${coin.symbol}</td>
</tr>`);
}
const tlable = document.querySelector('.nsrtHeer');
tlable.innerHTML =
`<table>
<caption>Top 20 coins</caption>
<tr>
<th>name</th>
<th>symbol</th>
</tr>
${trows.join('')}
</table>`;
});
} catch (error) {
console.log('fetch error: ' + eror);
} // try-catch()
}
window.onload = goGetIt();
</script>
</head>
<body>
<div class='nsrtHeer'></div>
</body>
</html>