2

How can I read the response header of XHR call by $http in Angular (v8+) as its status is 302 and it is redirected by browser? In my case as the redirect url has a different origin, I only get an Unknown error from the code below:

return this.http.get('/oauth2/authorization/keycloak').pipe(
        map(res => {
          // never called
          console.log(res);
          return res;
        }),
        tap( res => {
          // never called
          console.log(res);
        }),
        catchError(err => {
          // prints "Unknown Error"
          console.log(err);
          return err;
        })
      );
RezKesh
  • 2,861
  • 2
  • 24
  • 35

1 Answers1

0

Take a look at https://angular.io/api/common/http/HttpInterceptor. You will need to check HttpResponse [https://angular.io/api/common/http/HttpResponse].

AhmerMH
  • 638
  • 7
  • 18