[英]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.