How to use debounce on async function? [duplicate] How to use debounce on async function? [duplicate] vue.js vue.js

How to use debounce on async function? [duplicate]


Lodash's debounce function takes in a function , time to wait and returns a function.

So do it like this:

methods: {  getAlbums: _.debounce(async function() {    const response = await AlbumService.fetchAlbums();    this.albums = response.data.albums;  }, 1000);}