I want to run a method inside a v-for in my Vue component. Example:
<div v-for="(foo,index) in bar">
<p>{{myMethod(foo,index)}}</p>
</div>
When I do this the p-tag just stays empty. Here is my method(with an axios call):
myMethod:function(foo,index) {
axios.get('/myAjaxCall')
.then((response)=> {
//works perfectly
alert(response.data);
return response.data;
})
.catch(function (error) {
console.error(error);
});
},
}
When I alert( SomethingWithFooAndIndex), the browser is showing exactly what I need. When I remove the axios call the method seems to work
Thanks!