0
I use the v-model
to play the value for the variable categoria_selecionada
, I own a API that searches the subcategory in the database by following the address as per id
past, for example passing the value 2 would be:
categories/2/subcategories
The question that I need to pass the value of this variable, passed through a <select>
, leaving the search link similar to this:
categories/{{categoria_selecionada}}/subcategories
mounted() {
this.buscarCategoriasProfissional()
this.buscarSubCategoriasProfissional()
},
methods: {
buscarCategoriasProfissional() {
request.get(app.api + 'categories', ).then(response => {
this.categoria_profissional = response.data.data
})
},
buscarSubCategoriasProfissional() {
request.get(app.api + 'categories/' + {{categoria_selecionada}} + '/sub_categories',).then(response => {
this.sub_categoria_profissional = response.data.data
})
}
}
Remove the keys "{{categoria_selected}}" leaving only "categoria_selected". You may need to call with "this." or "vm." depending on how your scope is.
– Leonardo Getulio