获取两个URL Java脚本
如何从此数组调用数据? 我必须添加其他URL的两个值。 在此处输入图像描述
<table id="sales_table">
<thead>
<tr id="sales_item_title"></tr>
</thead>
<tbody>
<tr id="sales_item"></tr>
</tbody>
</table>
<script>
async function init(){
try{
const results = await Promise.all([
fetch('https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=PLN').then((response)=> response.json()),
fetch('https://min-api.cryptocompare.com/data/all/coinlist')
.then((response)=> response.json()),
].map(promise=>promise.catch(error=>console.error)));
console.log(results);
document.querySelector('#sales_item').innerHTML = results.0.PLN
} catch (error) {
console.error(error);
}
}
init();
</script>
How to call data from this array??
I have to add two values from others urls.
enter image description here
<table id="sales_table">
<thead>
<tr id="sales_item_title"></tr>
</thead>
<tbody>
<tr id="sales_item"></tr>
</tbody>
</table>
<script>
async function init(){
try{
const results = await Promise.all([
fetch('https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=PLN').then((response)=> response.json()),
fetch('https://min-api.cryptocompare.com/data/all/coinlist')
.then((response)=> response.json()),
].map(promise=>promise.catch(error=>console.error)));
console.log(results);
document.querySelector('#sales_item').innerHTML = results.0.PLN
} catch (error) {
console.error(error);
}
}
init();
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您返回两个对象,并且可以通过键访问对象。在您的示例中。然后使用:
object.pln
。You return two objects and you have access to the object by key. In your example PLN . Then use :
object.PLN
.