【发布时间】:2020-12-18 14:42:52
【问题描述】:
我正在尝试从我的 json 中读取所有值,但收到此错误:
TypeError: Cannot read property 'forEach' of undefined
我做错了什么?
fetch(url, {
method: 'POST',
headers: {
"user-key": 'mykey'
},
body:
'fields id, name, cover.url; where id = 1942;'
})
.then(response => response.json())
.then((data) => {
data.array.forEach(element => {
console.log(element)
});
})
.catch((error) => console.log(error))
【问题讨论】:
标签: javascript arrays json ajax api