DVV,
css сами пропишите.
(function() {
function exchangeDataShow() {
fetch('https://api.coinmarketcap.com/v1/ticker/?limit=20')
.then( (responce) => {
return responce.json();
})
.then( (data) => {
let output = ' ';
data.forEach(coin => {
let cls = coin.percent_change_1h < 0 ? 'red' : 'green';
output += `
<tr>
<td>${coin.rank}</td>
<td>${coin.name}</td>
<td>${coin.price_usd}</td>
<td>${coin['24h_volume_usd']}</td>
<td>${coin.market_cap_usd}</td>
<td>${coin.total_supply}</td>
<td>${coin.max_supply}</td>
<td class="${cls}">${coin.percent_change_1h}%</td>
<td>${coin.percent_change_24h}%</td>
<td>${coin.percent_change_7d}%</td>
</tr>
`;
});
document.getElementById('market-data').innerHTML = output;
})
.catch( (err) => {
console.log(err);
});
}
window.onload = exchangeDataShow();
setInterval(() => {
console.log('reload');
exchangeDataShow();
}, 5000);
})();