title: Concatenation of Angular http requests
body: <p>I am facing the following scenario.
  There is a Front End app, built with Angular(2), which is connected with a REST Back End accessible via http.
  Once an user logs in (using email and pwd), the Back End returns data related to the user and in particular an id associated with the user (let's call this <strong>userId</strong>) and the code of the region where he lives (let's call this <strong>regionId</strong>).
  Via the <strong>userId</strong> I can query the Back End to get the affinity group ID to which the user belongs (let's call this <strong>affinityId</strong>).
  Finally, using <strong>affinityId</strong> and <strong>regionId</strong> I can retrieve from the Back End the <strong>discount</strong> to apply to the user.</p>
  
  <p>In other words, the Back End offers 3 APIs:</p>
  
  <ul>
  <li>getUserData(email: string, pwd: string) : returns all user data including <strong>userId</strong> and <strong>regionId</strong></li>
  <li>getAffinityPerUser(userId: number) : returns a number representing the <strong>affinityId</strong></li>
  <li>getDiscount(regionId: number, affinityId: number) : returns a number representing the <strong>discount</strong></li>
  </ul>
  
  <p>If I access these APIs via Angular http client I can build the following APIs (in a sort of Javascript pseudo code)</p>
  
  <ul>
  <li>getUserData(email: string, pwd: string) : Observable(&lt;{userId,
  regionId, ...}>)</li>
  <li>getAffinityPerUser(userId: number) : Observable()</li>
  <li>getDiscount(regionId: number, affinityId: number) :
  Observable()</li>
  </ul>
  
  <p>I would like to know if I can combine such Observables using the RxJs operators to obtain the <strong>discount</strong> info which I am looking for.</p>
  
  <p>I can concatenate the first 2 APIs via switchMap to get the <strong>affinityId</strong> with something like</p>
  
  <pre><code>this.getUserData(email, pwd)
       .switchMap(userData =&gt; this.getAffinityPerUser(userData.userId))
  </code></pre>
  
  <p>but then I do not know how to combine the <strong>affinityId</strong> Observable (returned by <code>getAffinityPerUser</code>) with the userData Observable (returned by <code>getUserData</code>) to be able to have both <strong>affinityId</strong> and <strong>regionId</strong> which I need to call the getDiscount API.</p>
  
  <p>Any help is very much appreciated</p>