Good morning, thanks in advance for the help you could give me. I'm creating a page for issuing an invoice in laravel with vue and axios. Before sending the invoice to record, I must verify if the total value of the invoice makes you a winner, that if so, it must be added to the detail of the invoice with zero cost (the detail is in items []). If the prize is obtained, the prize will be charged to the items and sent to record with laravel with axios post as you can see in the code. The problem I have is that laravel does not reach the line of the prize that was loaded at the end, only those who entered the page arrive, however on the page itself if you can see that the prize was charged, since immediately shows that I charge it with this.items.push ().
Why do I have this problem, maybe the axios.post does not wait for me to complete the calculate_premium method ?, I have to pause before doing the axios.post (), I do not know what to do, I need your help please.
Thank you.
...
data: {
...
items: []
},
...
calcular_premio: function() {
if(cumple_condicion) {
this.items.push({});
}
},
grabar_factura: function() {
//antes de grabar la factura verificamos si se hace acreeedor a un premio
this.calcular_premio();
//aqui mandamos a grabar mediante una ruta de laravel
axios.post('/ventas/grabar_venta_ventanilla', ...
},