How can I use debounce
on an async
function? I have a method within my vue
-app which reveives data from an API which calls the API continuosly which I want to avoid.
Here is my method:
methods: {
async getAlbums () {
const response = await AlbumService.fetchAlbums()
this.albums = response.data.albums
}
}
I've installed lodash
previously so how can I achieve that?
Lodash's
debounce
function takes in a function , time to wait and returns a function.So do it like this: