I have a very strange problem, I have the following code inside a VueJS component.
I'm developing a system where I choose the options through several checkboxes, and step the id of them for that my component below.
And I use the axios to make the request in the database and retrieving 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
outside of then (), I have the result I want, but it stays in an infinite looping, making requests through the axios, and if I put it inside then of course it will not return anything.
Does anyone know how I can retrieve what I want from the axios result and list within that same component?