-1

I have written service in Angular 5 which does a GET request to my backend using the HttpClient class.

My request looks like this:

headers =  new HttpHeaders().set('Content-Type', 'application/json')
                             .set('X-XSRF-TOKEN', 'sdfhjsdgh');

          const options = ({ headers: headers});
          this.http.get('http://127.0.0.1:8080/api/v1/display', options)
         .filter(data => data.status === 200 || data.status === 206)
         .map((res) => this.success(res))
         .catch((res) => this.failure(res, service));

How do I use response header? so I can check status code and all that.

Any help is very much appreciated.

Swapnil Yeole
  • 406
  • 3
  • 12
  • 26

1 Answers1

0
headers =  new HttpHeaders().set('Content-Type', 'application/json')
                         .set('X-XSRF-TOKEN', 'sdfhjsdgh');

      this.http.get('http://127.0.0.1:8080/api/v1/display', {
        headers: headers,
        params: params,
        observe: 'response'})
     .filter(data => data.status === 200 || data.status === 206)
     .map((res) => this.success(res))
     .catch((res) => this.failure(res, service));
Swapnil Yeole
  • 406
  • 3
  • 12
  • 26