Closed Soontao closed 4 years ago
I am not familiar with Vue, but seems like you can use setInterval
?
let api = 'https://api2019ncovnews.herokuapp.com/api';
if (process.env.NODE_ENV !== 'production') {
api = 'http://localhost:9919/api';
}
setInterval(function() {
this.loading = true;
fetch(api)
.then(res => {
return res.json();
})
.then(res => {
this.title = res.title;
this.link = res.link;
this.data = res.items;
this.loading = false;
});
}, 300000); // 5 minutes
However due to #1 , there is a delay (about 1~2 hour or so) between when the new message is published on Telegram and when the API response includes the new message.
great idea. I will update it now.
I am not familiar with Vue, but seems like you can use
setInterval
?let api = 'https://api2019ncovnews.herokuapp.com/api'; if (process.env.NODE_ENV !== 'production') { api = 'http://localhost:9919/api'; } setInterval(function() { this.loading = true; fetch(api) .then(res => { return res.json(); }) .then(res => { this.title = res.title; this.link = res.link; this.data = res.items; this.loading = false; }); }, 300000); // 5 minutes
However due to #1 , there is a delay (about 1~2 hour or so) between when the new message is published on Telegram and when the API response includes the new message.
@whc2001 It does have a delay(1~2 hours). I will write another crawlar to solve this as soon as possible.
It's solved. (5 minutes.)
https://github.com/thegreatjavascript/2019-nCoV-News/blob/3c8207f57d585c7160283fa6d72d57eb74526e7b/src/components/HelloWorld.vue#L65-L78
Maybe we could add a function which refresh data every 1 minute ? So that users can share it on the TV / monitor.
Be Health, Thanks. :)