Well, this is not so, when you are extractDatatrying to turn to your function this.serviceData, you have not reported this to your service anywhere.
Try:
private extractData(res : any){
if(res.status < 200 || res.status >=300){
throw new Error('Bad response sttus:' + res.status);
}
let serviceData = res.json();
return serviceData || {};
}
Another option is that you actually declare serviceData in your service, then you can use it thisin your function.
export class GeoService {
private serviceData;
....
private extractData(res : any){
if(res.status < 200 || res.status >=300){
throw new Error('Bad response sttus:' + res.status);
}
this.serviceData = (res.json());
return this.serviceData || {};
}
}
, , , OnInit :
data;
constructor(private geoService: GeoService) {
this.geoService.loaddata()
.subscribe(data => {
this.data = data;
console.log(this.data);
});
}
OnInit.