【问题标题】:Read the response header when the status is 302 in AngularAngular 中状态为 302 时读取响应头
【发布时间】:2020-04-06 11:01:55
【问题描述】:

我如何读取 Angular (v8+) 中 $http 调用的 XHR 的响应标头,因为它的状态为 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;
        })
      );

【问题讨论】:

    标签: angular ajax angular-httpclient http-redirect angular-httpclient-interceptors


    【解决方案1】:

    【讨论】:

    • 第二页没有找到!
    • 不管你是否在拦截器中都无济于事,在这种情况下你无法访问第一个请求的标头
    猜你喜欢
    • 2023-03-11
    • 2015-10-08
    • 2020-05-26
    • 2015-08-31
    • 2019-06-27
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多