Fetch data once with Observables


#1

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 error
please help me out how can i fixed that
Thanks in andvance


#2

Hi@flycoders_sourav
Can you show your HTML code?
I think the issue is you are trying to iterate an object.
Iteration only possible with array?
If you want to do it ,you have to push the objects in to an array
Hope you understood :smiley: