我正按照教程尝试构建加密货币计算器。
但是,控制台中出现两个以下错误:
1)GET https://api.coinmarketcap.com/v1/ticker/净:: ERR_BLOCKED_BY_CLIENT
2)index.html:1未捕获(承诺)TypeError:无法获取
class UI{
constructor(){
this.init();
}
init(){
this.printCryptoCurrencies();
}
// Prints the options for the form
printCryptoCurrencies(){
cryptoAPI.getCryptoCurrenciesList()
.then(data => {
const cryptoCurrencies = data.cryptoCurrencies;
})
}
}
class CryptoAPI{
// Get all the cryptocurrencies
async getCryptoCurrenciesList(){
const url = await fetch('https://api.coinmarketcap.com/v1/ticker/');
//Return as JSON
const cryptoCurrencies = await url.json();
// Return the object
return{
cryptoCurrencies
}
}
}
// Instantiate the classes
const cryptoAPI = new CryptoAPI();
const ui = new UI();
能请你帮忙吗?