// dip service var dip = new Vue({ el: '#dip', data () { return { dipjson: {"ip": "", "hostname": "", "city": "", "country": ""}, returnstring: "", autorefresh: false, interval: null, } }, mounted () { this.updateIP(); this.runTimer(); }, methods: { updateIP: function () { axios.get("https://ip.paulbsd.com/json") .then(response => { this.dipjson = response.data; if (this.dipjson.hostname != "") { this.returnstring = this.dipjson.ip + '/' + this.dipjson.hostname; } else { this.returnstring = this.dipjson.ip; } }) .catch(err => { }); }, runTimer: function () { if (this.autorefresh) { this.interval = setInterval(this.updateIP,10000); } } } } );