I am currently utilizing a text field from the Vuetify library to filter a table within my application.
<v-text-field
style="min-width: 300px;"
v-model="filterString"
label="Search" />
The functionality is straightforward - whenever the user enters a new filter value, the table content should be updated. There is no need for a submit button as the filtering process is handled on the backend, requiring a request to be sent to the API for each update. I am using a Vue.js watcher to trigger the API request when the filter string changes.
watch: {
async filterString() {
// logic to communicate with the API
},
},
However, I am facing an issue where if the user types a 10-letter string in the search box, my application sends 10 unnecessary requests to the API. I am considering implementing a delay before sending a request or subscribing to an event that indicates when the user has finished typing. How can I ensure that a request is only sent after the user has finished typing in the text box? Any suggestions would be greatly appreciated.