使用CoinDesk API获取比特币价格指数实时数据

时间:2018-10-05 06:28:26

标签: javascript php html json

我的这种黑客行为是否有助于从Coindesk的API检索实时数据?我本着极大的热情写了这篇文章,但我希望有专业人士可以帮助编写更清晰的代码?

记下www.cointelegraph.com

这会执行预期的吗?

// Request Variable
var rqst = new XMLHttpRequest();

// GET request on the URL endpoint
rqst.open('GET', 'https://api.coindesk.com/v1/bpi/currentprice.json', true);

rqst.onload = function () {

//store JSON in data variable
var data = JSON.parse(this.response);

//loop over data to retrieve specific thing
data.forEach(bpi => {

// do something with data like; append to header in HTML
});
}}
// Send request
rqst.send();

0 个答案:

没有答案