Skip to content

Commit 6b68d1f

Browse files
author
Alexander Vakhitov
committed
fix(callAPIMethod): ff & safari(isomorphic-fetch) doesn't support response.body
1 parent 4f0ffda commit 6b68d1f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/callAPIMethod.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ export default function callAPI(
2626

2727
return fetch(url, {...defaults.fetchOptions, ...fetchOptions, ...options})
2828
.then( result => {
29-
const promiseCallback = result.body ? result[method]() : new Promise(resolve => resolve(result.body));
29+
const promiseCallback = result[method]();
3030

3131
if (result.ok) {
3232
return promiseCallback;
3333
}
3434

3535
return promiseCallback
36+
.catch( () => {
37+
throw new APIError(result.status, result.statusText);
38+
})
3639
.then( body => {
3740
throw new APIError(result.status, result.statusText, body);
3841
});

0 commit comments

Comments
 (0)