methods: {
getData() {
if(!this.token) {
console.log("token is null")
return
}
let tokenBody = {
"Content-Type": "application/json",
}
let itemsArr = []
this.bymbolArr.forEach(async item => {
console.log(item)
let tokenBody = {
"Content-Type": "application/json",
}
let data = await post(Config.getSharesUrl, tokenBody);
if (data.RetrieveItem_Response_3) {
let dataArr = data.RetrieveItem_Response_3.ItemResponse[0].Item[0].Fields.Field;
if(dataArr.length > 0) {
var obj = {}
let arr = dataArr.forEach( item => {
if(item.Double) {
obj[item.Name] = item.Double
}
})
}
}
let itemObj = {}
itemObj[item] = obj
console.log("itemibj="itemObj)
itemsArr.push(itemObj)
})
console.log("itemsArr=" + itemsArr)
this.items = itemsArr
}
the post after await is used with ajax, encapsulated by permise with async and await. The result shows that itemsArr= is empty, and then each item of itemibj= is displayed. What is the cause?