vue axios请求怎么获取 Response中的自定义headers

vue axios请求怎么获取 Response中的自定义headers


米琪卡哇伊
浏览 17966回答 2
2回答

zhhdiy

后端发送请求的时候设置:// 自定义响应头ctx.res.setHeader('myheader', 'abc')// 通过此header设置允许前端访问ctx.res.setHeader('Access-Control-Expose-Headers', 'myheader')前端就可以获取了response.headers['myheader']

慕田峪4524236

{  // `data` is the response that was provided by the server  data: {},  // `status` is the HTTP status code from the server response  status: 200,  // `statusText` is the HTTP status message from the server response  statusText: 'OK',  // `headers` the headers that the server responded with  // All header names are lower cased  headers: {},  // `config` is the config that was provided to `axios` for the request  config: {},  // `request` is the request that generated this response  // It is the last ClientRequest instance in node.js (in redirects)  // and an XMLHttpRequest instance the browser  request: {}}axios
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript