I am using Axios and Vuex in a Vue app which queries the iTunes API, but having problem with getting the entered value from the search/text field. An error is shown for the params argument in the query string. Code is below.
Search box
<v-text-field
v-model="search"
autofocus
@keyup.enter="searchData(params)"
label="Enter Artists Name"
append-icon="search">
</v-text-field>
And the searchData function is
async searchData({ params }) {
let config = {
headers: {
'Accept': 'application/json'
}
}
const response = await this.$http.get(`https://itunes.apple.com/search? term=${params.id}&entity=album`, config);
//store.commit('add', response.data.results);
console.log(response.data.results);
}
}
The error is
Cannot read property 'id' of undefined
at keyup.
So trying to pass the artist name which is put in search box, but not working?
Any tips welcome, Thanks
paramsa computed property which uses thesearchdata property (field value)? Isparamsan Object with aparamsproperty? If not, please show whereparamscome from. But I find it weird that you doasync searchData({params})instead of justsearchData(params)