zoukankan      html  css  js  c++  java
  • Vuejs之axios获取Http响应头

    今天在开始接入后端Api 就遇到了一个问题了 在用 axios 获取 respose headers 时候获取到的只有的 Object { cache-control:"private, must-revalidate", content-type:"application/json" } 下面是服务器返回的响应头, 我需要拿到的是 Authorization clipboard.png 使用 respose.headers 拿到的只用两个默认的headers, 尝试了使用捕获响应头的方法 axios.interceptors.response.use(function (response) { // Do something with response data console.log(response); return response; }, function (error) { // Do something with response error return Promise.reject(error); }); 结果打印出来的还是 Object { cache-control:"private, must-revalidate", content-type:"application/json" } 找了半天问题, 后面的在一个论坛找到了解决方法 原来在默认的请求上, 浏览器只能访问以下默认的 响应头 Cache-Control Content-Language Content-Type Expires Last-Modified Pragma 如果想让浏览器能访问到其他的 响应头的话 需要在服务器上设置 Access-Control-Expose-Headers Access-Control-Expose-Headers : 'Authorization' 前端成功获取Authorization clipboard.png 原文地址 :http://stackoverflow.com/ques...

    https://segmentfault.com/a/1190000009125333?utm_source=tag-newest

  • 相关阅读:
    SytemC on CentOS 5.3 64bit
    Fast Poisson Disk Sampling
    Geometry Imager Viewport Filter
    Dinornis – Rendering your Model in Mudbox by RenderMan Directly !
    Models of biological pattern formation
    OrthoLab
    如何编译ATILA GPU Emulator
    感受谷歌地图
    树状列表完成
    获取地图标记点经纬度
  • 原文地址:https://www.cnblogs.com/shaozhu520/p/10876744.html
Copyright © 2011-2022 走看看