-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
58 lines (51 loc) · 1.77 KB
/
index.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>CoinMarketCap</title>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
</head>
<body>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item active" aria-current="page">Coin Market Cap</li>
</ol>
</nav>
<div class="d-flex p-3 bd-highlight">
<div id='coins'></div>
</div>
<script type="text/javascript">
// My api key
var apikey = {
key: 'b0f8ad1f-c176-4b47-8774-e7e6e18be7e7'
}
// GET Fetch Requisition
fetch('https://pro-api.coinmarketcap.com/v1/cryptocurrency/map?CMC_PRO_API_KEY=' +
apikey.key)
.then((response) => {
if(!response.ok) throw new Error('Erro ao executar a requisição, status ' + response.status);
return response.json();
})
.then((api) => {
var texto = "";
// Get 10 coins and symbols
for(let i = 0; i < 20; i++){
// Show API information
texto = texto + `
<div class="media">
<img src="./assets/img/coin.jpg" class="align-self-center mr-3" alt="coin" width="100" height="60">
<div class="media-body">
<h5 class="mt-2">${api.data[i].name}</h5>
<p>${api.data[i].symbol}</p>
</div>
</div>
`;
document.getElementById("coins").innerHTML = texto;
}
})
.catch((error) => {
console.error(error.message);
});
</script>
</body>
</html>