3
I have a very strange problem, I have the following code inside a component of Vuejs.
I am developing a system where I choose the options through several checkboxes, and pass their id to that my component below.
And I use Axios to request the database and retrieve the data I need.
See below for the component.
<template>
<div>
<ul>
{{ modulos_encontrados }}
</ul>
</div>
</template>
<script>
export default {
props:['turmas_checked'],
data () {
return {
modulos:[]
}
},
computed:{
modulos_encontrados(){
if(this.turmas_checked.length > 0){
axios.get(`/modulos/${this.turmas_checked}`)
.then(response => {
this.modulos = response.data;
});
}
}
}
}
</script>
And if I call the this.modulos
out of the then(), I have the result I want, but it stays in an infinite looping, making requests through the Xios, and I put myself inside the then of course will not return anything.
Does anyone know how I can retrieve what I want from the Axios result and list within that same component ??
Console.log(this.turmas_checked) returns what?
– Marconi
Returns the ids I need, the queries in the database I can do normally, the problem is to list these results in the template, and when I do a Return out of then() it is making infinite requests.
– Alexandre Cardoso