I am attempting to implement a search and have an input were a user types in a search term and every 1.5 seconds i want it to hit the endpoint to get the search results. Right now I have an input like this
<input v-model="term" type="text" class="form-control" placeholder="Search"
v-on:input="search($event.target.value)" @focusin="enableSearch" @focusout="clear">
The I have a function that is throttled using lodash throttle method to call the endpoint.
search: _.throttle(function (term) {
if (this.term != null && this.term.length > 3) {
this.toggleSearch();
this.searchQueue(term)
}
}, 1500),
now when i type in a search term like "Joe D" instead of getting one call to the endpoint i get 4. It looks like i get a endpoint call for each key press.
Not sure why the throttling is not working. Any help would be appreciated.