How to run http.get every x seconds in ionic2


#1

Hi guys, is there someone can help me how to How to run http.get every x seconds in ionic2?
So I can get the updates json from remote server.

Thank you


#2

just make a recursive methode that calls itself something like this:

        `public getAll() {
         vare me =this;
         setTimeout(function(){
         return me.http.get(this.url, me._options);
         me.getAll()
         },2000)`

this will run every 2 seconds
but also remember it is always good to have a condition to break the loop.

also if this looses reference to the this object you can always pass it as an argument


#3

Thank you Sgouromallis. It’s worked!