【发布时间】:2021-10-25 22:18:59
【问题描述】:
我想在控制台日志中显示我从这段代码中获得的数据(它是 JSON 格式)并在 HTML 中显示它。我应该使用哪种方法?
async function getAVA() {
fetch('https://graphql.avascan.info', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
query {
stats {
priceAvaxUsd
}
}`
}),
})
.then((res) => res.json())
.then((result) => console.log(result));
}
getAVA();
【问题讨论】:
标签: javascript jquery json fetch-api