0
If you need to pull data in your Vue component, you do that on the beginning of the Vue instance life cycle (onCreate, created, mounted, etc.) Then you change an attribute (key in data
) of the instance that already exists since the initiation of the instance.
<tbody>
<tr div v-for="invoices in invoice">
<th scope="row">{{invoices.p_id}}</th>
<td>{{invoices.p_amount}}</td>
<td>{{invoices.p_qty}}</td>
<td>{{invoices.p_amount}}</td>
<td>
<!-- here i need call method and and print its data: -->
{{refund}}
</td>
</tr>
</tbody>
script
export default{
data(){
return {
invoice:{},
refund: "" // data not pulled yet
}
},
methods:{
IsAvaiabaleRefund(p_id,incoice_id){
axios.get('/check-refund-data/'+p_id+'/'+incoice_id)
.then(function (response) {
console.log(response.data);
this.refund = response.data;
})
}
},
created(){
axios.get('/refund-data/002').then(response => {
this.invoice = response.data.invoice
console.log(response.data.invoice);
IsAvaiabaleRefund(invoices.p_id,'002')
})
.catch(error => {
console.log(error);
})
}
}
Source:stackexchange.com