Vue
HTML
<div id="app">
Request done: {{ requests }}
</div>
Vue
new Vue({
el: '#app',
data: { requests: 0 },
methods: {
search: _.throttle(async function (vm) {
const res = await fetch('/echo/json/')
this.requests++
console.log(res)
}, 1000)
},
created () {
// 100ms interval but throttle works at 1000ms
setInterval(() => {
this.search()
}, 100)
}
})