Reputation: 1320
i have a computed property and inside it has axios call. that computed propery i need to loop and show result using v-for
.
my computed property looks like this.
computed:{
managers(){
axios.post('/dispatcher/managers',{
'catId':this.catId,
'route':this.filters.selectedRoute,
'date':this.filters.selectedDate,
'manager':this.filters.selectedManager
}).then(response=>{
return response.data;
}).catch(err=>{})
}
}
When i try to loop managers
using v-for
it does not work.
How can i get it to work? Thanks.
Upvotes: 2
Views: 4063
Reputation: 15472
According to the docs, you should probably use a watcher: https://v2.vuejs.org/v2/guide/computed.html#Watchers
In this case, using the watch option allows us to perform an asynchronous operation (accessing an API), limit how often we perform that operation, and set intermediary states until we get a final answer. None of that would be possible with a computed property.
Upvotes: 3