title: Angular4 - Nested Http Calls
body: <p>I'm using a http nested call in angular.</p>
  
  <p><strong>First</strong> Call to get a token.
  <strong>Second</strong> call will be using token and returning actual data. </p>
  
  <pre><code>  public get(api) {
      return this.http.get(this.url + '/token')
        .map(res =&gt; res.json())
        .toPromise()
        .then((data: any) =&gt; {
          this.access_token = data.access_token
          let headers = new Headers();
          headers.append('Authorization', 'Bearer ' + this.access_token);
          return this.http.get(this.url + api, {
            headers: headers
          }).map(res =&gt; res.json());
        })
    }
  </code></pre>
  
  <p>The function returns <code>Promise&lt;Observable&lt;any&gt;&gt;</code>. How to parse the response so i can get the data from nested call in a subscription.</p>
  
  <pre><code>this.get('me/profile')
      .subscribe(data =&gt; {
           console.log(data);
        });
  </code></pre>