[英]Read the response header when the status is 302 in Angular
我如何读取 Angular (v8+) 中$http
调用的XHR
的响应 header,因为它的状态是 302 并且它被浏览器重定向? 在我的情况下,由于重定向 url 具有不同的来源,我只从下面的代码中得到一个未知错误:
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;
})
);
看看https://angular.io/api/common/http/HttpInterceptor 。 您需要检查 HttpResponse [ https://angular.io/api/common/http/HttpResponse] 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.