【发布时间】:2016-05-26 18:43:59
【问题描述】:
所以基本上我使用 fetch POST 或 PATCH 方法发送数据,当我遇到错误时,我可以在网络中看到 -> 响应此错误:
{
"Errors": [
{
"Code": -201,
"Message": "Could not get file from link",
"AssociatedError": "404 Not Found"
}
],
"Result": null
}
这是我的实际代码:
function checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
return response;
} else {
var error = new Error(response.statusText);
error.response = response;
throw error;
}
}
export function sendImageUploaded(data, valueMethod, endpoint) {
return dispatch => {
dispatch(requestPosts(data));
return fetch(endpoint, {
method: valueMethod,
headers: new Headers({
Authorization: Isengard.config.token
}),
body: data
})
.then(checkStatus)
.then(reponse => {
dispatch(successSent("The output list has been successfully sent!"));
}).catch(err => {
console.log('request failed', err);
dispatch(failSent("Error on sending request: " + err));
});
};
};
我正在为收到此错误消息而苦苦挣扎。
【问题讨论】:
标签: javascript reactjs xmlhttprequest