Hi Guys, I'm trying to call CoinBase's API for up-to-date Bitcoin price for a website I'm trying to create. I'm trying to make it using javaScript. Below is the code I have come up with but I am a bit stuck with it..... I was hoping someone here might point me in the right direction?
<!DOCTYPE html>
<html>
<head>
<title> Call coindesk API</title>
</head>
<body>
<script>
function httpGetAsync( "
https://api.coindesk.com/v1/bpi/currentprice.json", callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", "
https://api.coindesk.com/v1/bpi/currentprice.json, true)"; // true for asynchronous
xmlHttp.send(null);
}
</script>
</body>
</html>