Skip to content

Instantly share code, notes, and snippets.

@turtlepile
Last active June 9, 2022 20:08
Show Gist options
  • Save turtlepile/f75a7c40941e424de0b340a1b4a42246 to your computer and use it in GitHub Desktop.
Save turtlepile/f75a7c40941e424de0b340a1b4a42246 to your computer and use it in GitHub Desktop.
debounce function
loadEntries: _.debounce(function (searchInput) {
this.customerSearchLoading = true;
this.externalUserItems = [];
this.customers = [];
if (searchInput != null && searchInput.length > 2) {
const accountFormData = {
SearchText: searchInput,
CanikId: searchInput,
};
axios({
method: "post",
url: "GetExternalAccounts",
data: qs.stringify(accountFormData),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json",
},
})
.then((response) => {
if (response.data == "NOK") {
this.externalUserItems = [];
this.customers = [];
this.customerSearchLoading = false;
console.log(this.customers);
} else {
this.customerSearchLoading = false;
this.externalUserItems = response.data;
this.customers = response.data;
}
})
.catch(() => {
this.customerSearchLoading = false;
this.externalUserItems = [];
this.customers = [];
});
} else {
this.customerSearchLoading = false;
}
}, 500),
@turtlepile
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment