i want to fetch data once with Observables
below my code. editprofile.ts
ionViewDidLoad() {
this.editProfile()
}
editProfile() {
this.storage.get('userid').then((val) => {
this.userid=val
this.tosatService.presentLoading('Fetching data for you');
let subscription:Subscription = this.service.editProfile(this.userid).subscribe(data => {
this.tosatService.dismissLoading();
this.services=data;
}, err=> {
this.tosatService.dismissLoading();
this.tosatService.presentErrorAlert("Unable to Fetch data for you, We are so");
});
this.subscriptions.push(subscription);
});//storage
}
}
service.ts
public editProfile(userid:any):Observable<Array<EditprofileRequest>> {
const myHeaders = new HttpHeaders({'Content-Type':'application/x-www-form-urlencoded', 'Accept':'application/json '});
return this.http
.get<Array<EditprofileRequest>>(this.config.apiBase +'/editprofile'+'/'+userid)
.concatMap(data => {
return Observable.of(data);
});
}
edidprofile.model.ts
export class EditprofileRequest {
username:string;
email: string;
name: string;
mobile: string;
password: string;
}
showing this errorplease help me out how can i fixed that
Thanks in andvance