Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Lovera authored and Joel Lovera committed May 2, 2016
1 parent 50590b5 commit dc35561
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,30 @@ class Client {
_url = _url+separator+this.toQueryString(body);
}
} else {
_body = JSON.stringify(body);
_body = JSON.stringify(body);
}

let checkStatus = (response) => {
if (response.status >= 200 && response.status < 300) {
return response;
} else {
let error = new Error(response.statusText);
error.response = response;
throw error;
}
if (response.status >= 200 && response.status < 300) {
return response;
} else {
let error = new Error(response.statusText);
error.response = response;
throw error;
}
}

let parseJSON = (response) => {
return response.json();
if (response.statusText === 'No Content') {
return { type: 'undefineds' };
}
return response.json();
}

return fetch(_url, {
method: method || 'GET',
headers: _headers,
body: _body
method: method || 'GET',
headers: _headers,
body: _body
}).then(checkStatus)
.then(parseJSON)
};
Expand Down

0 comments on commit dc35561

Please sign in to comment.