I am trying to implement getting data from API with params. I got two functions for that and I can't see the error. Any ideas?
getFilteredProducts() {
return apiClient.get('/product/', {
params: {
search: String(name)
}
})
}
async fetchFilteredProducts({ commit }, name) {
await productService.getFilteredProducts({name})
.then(response => {
commit('SET_FILTERED_PRODUCTS', response.data.items)
})
.catch(error => {
console.log('Error has occured' + error)
})
}
I received working solutions with the code below, so the problem probably with the second parameter.
async fetchFilteredProducts({ commit }, name) {
await axios.get("MY_API_URL/product/", {
params: {
search: String(name)
}
})
.then(response => {
commit('SET_FILTERED_PRODUCTS', response.data.items)
})