<div>
BTC / ETH =
<span class="demo">…</span>
</div>
const prefix = 'https://api.coingecko.com/api/v3/coins/';
Promise.all(
['bitcoin', 'ethereum'].map(
c => fetch(prefix + c).then(response => response.json())
)
)
.then(rates => {
const [rateBTC, rateETH] = rates.map(
rate => rate.market_data.current_price.rub
);
document.querySelector('.demo').innerText = rateBTC / rateETH;
})
.catch(console.error);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.