-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
53 lines (49 loc) · 1.85 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CoinMarketCap</title>
<link rel="stylesheet" type="text/css"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div id="coins"></div>
<script>
//My api key
var apiKey = {
key: '85d1d17b-3769-4815-84d5-afe874cc9441'
}
//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<10; i++) {
console.log(api);
//Show API informations
texto = texto + `
<div>
<div class="media">
<img src="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>
<p>${api.data[i].first_historical_data}</p>
</div>
</div>
</div>
`;
document.getElementById("coins").innerHTML = texto;
}
})
.catch((error)=> {
console.error(error.message);
});
</script>
</body>
</html>