Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧐[问题 | question] responseInterceptors 中如何获取response 全部headers? #11376

Open
beijipc opened this issue Oct 21, 2024 · 0 comments

Comments

@beijipc
Copy link

beijipc commented Oct 21, 2024

🧐 问题描述 | Problem description

预期:接口会在response header中返回一些信息,比如token。我在响应拦截器中读取header
问题:拦截器的header内容只返回了content-length和content-type,与浏览器看看到的header不一致,导致我取不到token

💻 示例代码 | Sample code

responseInterceptors: [
    (response: AxiosResponse) => {

      console.log('response headers:', response.headers);
      // 打印只有得到content-length和content-type
     
      const { data, config } = response

      if (!data?.success) {
        message.error('请求失败!');
      }

      return data;
    },
  ],

token没有读取不到

image

🚑 其他信息 | Other information

浏览器 | browser:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant