I have a question, I am getting an array as a response from web api
Structure of response is simple:
interface CabinInfo {
id: number;
projectId: number;
cabinId: number;
ipAddress: string;
port: number;
}
So now I need to group it by projectId, so naturally i would use rxjs/operators to get some sort od array that i can iterate in html, so I am using:
this.clientService.GetAllApplications()
.subscribe(result => {
const projectsObservable: Observable<CabinInfo> = from(result);
const projectsList = projectsObservable.pipe(groupBy(cabin => cabin.projectId, cabin => cabin)
, mergeMap(group => group.pipe(map(() => ({ projectId: group.key, cabins: group.pipe(toArray())})))));
}, error => { console.error(error); });
But it does not work as I want, I expect something like
Array<number|CabinInfo[]>
all I am getting something complex like
Observable<{projectId: number, Observable<CabinInfo>[]}>
is there a way to convert it to simple array??