【发布时间】:2016-09-19 06:42:46
【问题描述】:
我正在使用 fetch API 调用 API 端点。
如何在已解决的正文承诺中读取响应 body 和 headers?
下面是我的代码sn-p:
fetch(url, {
credentials: 'include',
method: 'post',
headers: {
"Content-Type": "application/json; charset=utf-8",
},
body: JSON.stringify({
email: email,
password: password,
}),
})
.then(response => response.json())
.then(function(response) {
// How to access response headers here?
});
【问题讨论】:
标签: javascript fetch response-headers fetch-api