获取响应格式错误
Fetch response malformed
问题基本上是获取响应对象不正确。澄清问题的图片如下,因为很难解释。
我的获取请求代码。
fetch(this.constructUrl(url), {
method: method,
mode: 'no-cors',
headers: new Headers({
'Authorization': 'Bearer ' + this.token,
'Accept': 'application/json',
'Content-Type': 'application/json',
}),
body: new FormData(document.getElementById(formIdentifier))
}).then(function (response) {
if (response.ok) {
return response.json().then(callback);
}
console.log(response);
}).catch(function(error) {
console.log(error);
});
获取响应对象。
chromeresponse/request详情
chrome响应数据
正如您所见,chrome 中的数据看起来是正确的,但由于某种原因,获取响应对象似乎并未反映 chrome 获取的内容。
我不得不将 'no-cors' 切换为 'cors' 并在我的休息堆栈中允许 cors。
问题基本上是获取响应对象不正确。澄清问题的图片如下,因为很难解释。
我的获取请求代码。
fetch(this.constructUrl(url), {
method: method,
mode: 'no-cors',
headers: new Headers({
'Authorization': 'Bearer ' + this.token,
'Accept': 'application/json',
'Content-Type': 'application/json',
}),
body: new FormData(document.getElementById(formIdentifier))
}).then(function (response) {
if (response.ok) {
return response.json().then(callback);
}
console.log(response);
}).catch(function(error) {
console.log(error);
});
获取响应对象。
chromeresponse/request详情
chrome响应数据
正如您所见,chrome 中的数据看起来是正确的,但由于某种原因,获取响应对象似乎并未反映 chrome 获取的内容。
我不得不将 'no-cors' 切换为 'cors' 并在我的休息堆栈中允许 cors。