selectPreviousSearch(index) {
this.search = this.searchHistory.slice(-5).reverse()[index];
// this.search = this.searchHistory[index];
this.showSearchHistory = false;
const baseURI = 'api url...';
var container_id = JSON.parse(localStorage.getItem('anonymous_id'));
let accToken = localStorage && localStorage.loggedinUser ? localStorage.loggedinUser : null;
// eslint-disable-next-line
console.log('another call',accToken);
const headers = new Headers({
'access_token' : accToken,
'Content-Type': 'application/json',
});
var data={
'keyword': this.index,
}
axios.get(baseURI, data, {
headers: {
'access_token': accToken
}
})
.then((response) => {
this.users = response;
}, (error) => {
if (error) {
this.errorMessage = error.response.data.message;
}
}).catch(error => {
//this.errorMessage = error.response.data;
})
},
<li
v-for="(item, index) in searchHistory
.slice(-5)
.reverse()
.map((s) => s.trim())"
:key="index"
@click="selectPreviousSearch(index)"
>
{{ item }}
</li>
I want to pass index from the li to the axios? inside of the var data. So that when user clicked on data form the li. He will get the success response.
At present i am thinking that, I have not passed the value correctly, from the li So that i am unable to see proper response