If the response is not "ok", reject fetch

This commit is contained in:
Mahdi Dibaiee 2015-07-13 05:36:36 +04:30
parent daaa587aa2
commit 532f54db54

View File

@ -15,7 +15,8 @@ export default function fetch(path, data = {}) {
.field(data)
.attach(files)
.end(response => {
if (response.statusType === 4 || response.statusType === 5) {
if (response.statusType === 4 || response.statusType === 5 ||
!response.body.ok) {
reject(response);
} else {
resolve(response.body);