I want to query to different rest resources and want to combine the results into a single object. Its a user object and every user should contain a single role. I have read I can use flatMap to do this, but I cant make it work:
public getUsers(): Observable<User[]> { var users: Observable<User[]> = this.someService.getUsers('[A_URL]') // returns Observable<User[]> .flatMap(res=> { // for every user call resource 'role' and add it to user object one by one ... // return this.someService.getRoleByUser('[A_URL_WITH_USERID]') }.map(res=>{ //add role to user object // user.role = r; }); ); return users; } Im sorry for the pseudo code, but I really dont understand the syntax. The problem is, that the second resource call needs the id of every user from the first call.