0👍
I managed to make it work using the methods that the
Estus Flask mentioned (async/await).
If anyone has the same problem, here is the complete code:
new Vue({
el: '#app',
data () {
return {
}
},
async mounted () {
const tickets = document.getElementsByClassName('ticket')
for (let index = 0; index < tickets.length; index++) {
await axios
.get('/api/prices/' + tickets[index].innerText)
.then(response => {
tickets[index].nextElementSibling.textContent = response.data
})
.catch(error => console.log(error))
}
}
})
Source:stackexchange.com