What is the method to utilize Observable function for fetching data from server every 10 seconds?
Custom App service
fetchDevices (): Observable<Device[]> {
return this.http.get(this.deviceUrl)
.map(this.extractData)
.catch(this.handleError);
}
App Component
ngOnInit():void {
this.retrieveData();
this.showLastDeviceInterior();
this.displayOutDevice();
this.obtainSettings();
}
retrieveData()
{
this.dataService.fetchDevices().subscribe( devices => this.devices = devices,
error => this.errorMessage = <any>error);
}