I am encountering an issue with this code - when I attempt to add another filter inside the computed section, it doesn't work. However, if I remove the additional filter, the code functions correctly.
My goal is to have both company and product searches on a single page. The companies filter works without any issues, but as soon as I include the products filter, there are complications.
new Vue({
el: '#app',
data () {
return {
info: [],
products: [],
search: '',
prosearch: ''
}
},
mounted () {
axios
.get(`${URL}/api/`)
.then(response => (this.info = response.data))
axios
.get(`${URL}/api/`)
.then(response => (this.products = response.data))
},
computed:{
filterdata: function(){
return this.info.filter((info)=>{
return info.name.match(this.search)
});
},
AdditionalFilterData: function(){
return this.products.filter((product)=>{
return product.name.match(this.prosearch)
});
},
}
})