I wrote a service:
loadroom() : Observable<any[]>{
return this.http.get(this.roomUrl)
.pipe(
map((response: any) => {
let resources = response;
return resources.map(function(room:any) {
return {id: room.id, title: room.title, eventcolor: room.eventColor};
});
})
);
}
Then I use this service in a component
rooms: any[] = [];
ngOnInit() {
this.schedulerService.loadroom().subscribe(response => this.rooms = response);
console.log(this.rooms);
}
I didn't see data in the array. In console I get an empty array []
But if I use
this.schedulerService.loadroom().subscribe(response => {console.log(response)});
I get the data.