var vm = new Vue({ el: '#app', data: { timer: null, machineMeterDtos: [] }, mounted() { this.getMachineMeterDtos() }, methods: { getMachineMeterDtos() { let _this = this axios .get('/EnergyConsumptionMeterCheck/GetMachineMeterStates') .then(function (response) { _this.machineMeterDtos = response.data; }) .catch(function (error) { console.log(error) }); }, setTimer() { if (this.timer == null) { this.timer = setInterval(() => { this.getMachineMeterDtos() }, 60000) } }, clearTimer() { clearInterval(this.timer) this.timer = null } }, created: function () { this.clearTimer() this.setTimer() }, destroyed: function () { this.clearTimer() } })