Skip to content
Advertisement

Search input using a query using Vuex and Axios

I’m trying to make a search input where I input a query and that query gets added to the API call and returns me the data that I want, here’s a sample of my code

JavaScript

My JS:

JavaScript

My vuex module:

JavaScript

The search query is not getting passed on the input, if I put something on the query from the Vuex module I get the correct results but if I input something and click the search button I get the default results of the api JSON which means my input is not working, I’d appreciate some help and thanks in advance!

Advertisement

Answer

First thing is that your using v-bind incorrectly, better use v-model:

JavaScript

second thing organize better your code when you are using vuex, I would do it of this way:

Template:

JavaScript

JS:

JavaScript

VUEX:

JavaScript
Advertisement