title: Angular 2 - Get Headers From Http Requests
body: <p>All my Backend API requests return new token information in headers, even when them throw exceptions. In the next request I need to send these new token information.</p>
  
  <p>So I'm trying to figure out an unique and standard way to do that, so I'm trying:</p>
  
  <pre><code>let requestOptions = new RequestOptions(Object.assign({
        method: method,
        url: environment.apiHost + url,
        body: body,
        headers: authenticatedRequest ? this.requestService.getAuthHeaders() : this.requestService.getJsonHeaders(),
        withCredentials: authenticatedRequest
      }));
  
  this.http.request(new Request(requestOptions))
          .map((res:Response) =&gt; { this.storageService.setAuthInfo(res.headers); res.json() } )
          .catch((error:any) =&gt; Observable.throw(error.json().error || 'Server error'));
  </code></pre>
  
  <p>The problem I'm facing with is that when I <code>subscribe</code> to this method, <code>res</code> variable is returning <code>undefined</code>.</p>
  
  <p>What do you suggest me?</p>