3
我使用fetch API
调用API端点。 我该如何阅读回复正文和标题已解决主体承诺?如何读取正文/响应中的标头承诺
我的代码如下片段:
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?
});
我需要在我处理JSON的地方获取标题。 – LukasMac
在我的示例中,您可以在json方法中访问contentType – Ygalbel