Following is my api call, I have interceptor in between, so I am getting this data from localstorage. The data is stringified and saved. When I return it I convert into observable by observable.of(cachedata).
getApplications(userid: string): Observable<any> {
let data =this.httpclient.get(this._getAPIUrl('user/' + userid + '/applications'))
.map((res: Response) => res.json())
return data;
}
I called it from component
ngOnInit() {
const userid = this.platformService.currentUserId;
console.log(this.platformService.getApplications(userid));
}
it print result
Observable {_isScalar: false, source: Observable, operator: MapOperator}
if I subscribe this call data didn't get available.
this.platformService.getApplications(userid)
.subscribe(applications => {
console.log('app ' + applications);
const menuItems: MenuItem[] = [];
menuItems.push(
new MenuHeaderItem({
type: MenuItemType.Header,
title: 'Applications',
description: null
}));
Object.keys(applications).map(element => {
menuItems.push(this.formatconversion(applications[element]));
});
this.menu = menuItems;
});
console.log('app ' + applications) not coming.
Any help will be appreciated. Thanks in advance.