# How to auto update data on ionic page with out refreshing the page

**URL:** <https://forum.ionicframework.com/t/how-to-auto-update-data-on-ionic-page-with-out-refreshing-the-page/88843>\
**Category:** ionic-v3\
**Created:** [May 4, 2017, 5:21am UTC](https://forum.ionicframework.com/t/how-to-auto-update-data-on-ionic-page-with-out-refreshing-the-page/88843 "2017-05-04T05:21:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![umaa](https://avatars.discourse-cdn.com/v4/letter/u/439d5e/32.png) [@umaa](https://forum.ionicframework.com/u/umaa)\
**Post date:** [May 4, 2017, 5:21am UTC](https://forum.ionicframework.com/t/how-to-auto-update-data-on-ionic-page-with-out-refreshing-the-page/88843/1 "2017-05-04T05:21:32Z")

</div>

Hi,  
I created a page that contains a button, upon clicking on that i am calling a rest api that responses me some data and am showing it below the [button.so](http://button.so), when a click is made on the button again, the data changes on the view.but, i just wana do something like with out clicking on the button everytime, display the updated data from rest api.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [May 4, 2017, 5:31am UTC](https://forum.ionicframework.com/t/how-to-auto-update-data-on-ionic-page-with-out-refreshing-the-page/88843/2 "2017-05-04T05:31:49Z")

</div>

I suppose you could schedule a periodic task that does whatever clicking on the button does, but I would take some time to seriously think about whether your users really want this.

---

<div class="post-metadata">

**Author:** ![umaa](https://avatars.discourse-cdn.com/v4/letter/u/439d5e/32.png) [@umaa](https://forum.ionicframework.com/u/umaa)\
**Post date:** [May 4, 2017, 5:37am UTC](https://forum.ionicframework.com/t/how-to-auto-update-data-on-ionic-page-with-out-refreshing-the-page/88843/3 "2017-05-04T05:37:37Z")

</div>

Iet me make it more clear, its just like displaying a weather report, instead of user requesting evertime, just display the latest values.

---

<div class="post-metadata">

**Author:** ![Nexi](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/nexi/32/117290_2.png) [@Nexi](https://forum.ionicframework.com/u/Nexi)\
**Post date:** [May 4, 2017, 5:49am UTC](https://forum.ionicframework.com/t/how-to-auto-update-data-on-ionic-page-with-out-refreshing-the-page/88843/4 "2017-05-04T05:49:24Z")

</div>

Rxjs should work here, but haven’t tested it. Also error handling is missing.

```auto
import { Http } from '@angular/http';
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/interval';
import 'rxjs/add/operator/mergeMapTo';
import 'rxjs/add/operator/map';

@Component({
  selector: 'page-weather',
  template: `
    <ion-content>
    <h2>{{(data | async)?.city}}</h2>
    <p *ngIf="(data | async)">{{(data | async)?.degree}}°C</p>
    </ion-content>
  `
})
export class WeatherPage {
  data: any;
  constructor(private http: Http) {
    this.getWeather();
  }

  private getWeather() {
    this.data = Observable
    .interval(10000)
    .mergeMapTo(this.fetchWeatherData())
    .map(res => res.json());
  }

  private fetchWeatherData() {
    return this.http.get('http://myUrl.com/api/weather');
  }

}

```
