baseddata.io/layouts/shortcodes/bitcoin-price.html

20 lines
553 B
HTML
Raw Normal View History

2024-08-01 14:06:16 +01:00
<!doctype html>
<html>
<body>
<p id="price"></p>
<script>
2024-08-14 19:48:58 +01:00
fetch(`${"{{ .Site.Params.apiURL }}"}/get_json/final__price.json`)
2024-08-01 14:06:16 +01:00
.then((response) => response.json())
.then((data) => {
var lastElement = data[data.length - 1];
document.getElementById("price").innerHTML =
`The current price is: <em>$ ${lastElement.price.toLocaleString()}</em> (${lastElement.date}) `;
})
.catch((error) => {
console.error("Error:", error);
});
</script>
</body>
</html>