created () {
this.test();
},
test : function () {
axios.get('/api/1', {
headers : {
'Access-Control-Allow-Origin' : '*',
'session' : window.session_id
}
}).then((response) => {
for (const item of response.data) {
axios.get('/api/2', {
headers : {
'Access-Control-Allow-Origin' : '*',
'session' : window.session_id
}
}).then((response) => {
item.subscribers = response.data.filter(o => { return o.status > 0 }).length;
});
};
this.list = response.data;
}).catch((error) => {
console.log(error)
})
},
<tr v-for="val in list">
@{{ val.subscribers }}
</tr>
here i am not getting 'subscribers' in the template as it is loading after rendering or i m not sure. how can i use async/await to load all data then render to the view
TIA
question from:https://stackoverflow.com/questions/65641235/vue-js-async-inside-foreach-loop