title: Angular 4 get headers from API response
body: <p>I'm sending a request to an API, it returns an array of data, but I don't know how to extract the headers from that url, this is what i've tried in my service</p>
  
  <pre><code>@Injectable()
  export class ResourcesService {
  private resourcesurl = "http://localhost:9111/v1/resources";
  
  constructor(private http: Http) { }
  
  getResources() {
    let headers = new Headers();
    headers.append("api_key", "123456");
    return this.http.get(this.resourcesurl, { headers: headers 
   }).map(this.extractData).catch(this.handleError);
  }
  getresourceheaders(){
    let headers = new Headers();
    headers.append("api_key", "123456");
    let options = new RequestOptions();
    let testsss = options.headers
    let headerapi = this.http.request(this.resourcesurl, options);
    let test = this.http.get(this.resourcesurl, { headers: headers });
    console.log(headerapi);
  }
  private extractData(res: Response) {
    let body = res.json();
    return body.data || {};
  }
  private handleError(error: Response | any) {
  let errMsg: string;
  if (error instanceof Response) {
    const body = error.json() || '';
    const err = body.error || JSON.stringify(body);
    errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
  } else {
    errMsg = error.message ? error.message : error.toString();
  }
  console.error(errMsg);
  return Observable.throw(errMsg);
   }
  }
  </code></pre>
  
  <p>I want to get the headers from that response that in this case is <strong>resourceurl</strong></p>
  
  <p>any idea?</p>