Vue
by renatello
HTML
<script src="https://unpkg.com/[email protected]/dist/axios.js"></script>
<div id="app">
<h2>Polling:</h2>
</div>
Vue
new Vue({
el: "#app",
data () {
return {
polling: null
}
},
methods: {
pollData () {
this.polling = setInterval(() => {
axios
.get('https://dummy.restapiexample.com/api/v1/employees')
.then(response => (this.info = response))
}, 30)
}
},
beforeDestroy () {
clearInterval(this.polling)
},
created () {
this.pollData()
}
})