2 回答
TA贡献1条经验 获得超1个赞
后端发送请求的时候设置:
// 自定义响应头
ctx.res.setHeader('myheader', 'abc')
// 通过此header设置允许前端访问
ctx.res.setHeader('Access-Control-Expose-Headers', 'myheader')
前端就可以获取了
response.headers['myheader']
TA贡献1875条经验 获得超5个赞
{
// `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: {}
}
添加回答
举报