0

I am using the spatie datatables component, retrieving data asynchronously and pagination.

What I would like, is for a delay to be allowed for between each keyup in the filter box before issuing an ajax call to get the data.

Traditionally in JavaScript I would do this by adding a keyup event on the input with a timeout, but I'm not sure how to do this with a Vue component.

My current component method looks like;

async fetchData({ page, filter, sort }) {

    const response =  await axios.get(this.getUrl(), this.getParams({
        page: page,
        filter: filter,
        sort: sort
    }));

    return response.data;
}
Rooneyl
  • 7,802
  • 6
  • 52
  • 81

1 Answers1

0

You may take a look on combination with lodash.debounce method. Similar question posted here: How can I debounce using async/await?

Makarov Sergey
  • 932
  • 7
  • 21