您好,我想在获取 POST 请求后获取响应标头。我试着调试看看里面有什么 response
和 console.log(response)
。我可以从 responseData
获取响应主体,但我不知道如何获取标头。我想同时获得标题和正文。请帮忙。谢谢:)
这是我所做的示例:
fetch(URL_REGISTER, {
method: 'POST',
body: formData
})
.then((response) => response.json())
.then((responseData) => {
if(responseData.success == 1){
this.setState({
message1: responseData.msg,
});
}
else{
this.setState({
message1: responseData.msg,
});
}
})
.done();
},
原文由 user6487402 发布,翻译遵循 CC BY-SA 4.0 许可协议
你可以这样做
阅读有关 fetch 的更多信息:fetch() 简介