Skip to content

Commit

Permalink
Fix fetch adapter to handle custom json content type
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Feb 6, 2022
1 parent da4d378 commit 5de7be0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/httpadapter/fetchadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ class FetchAdapter {
url + '?' + querystring.encode(params),
options
);
const contentType = res.headers.get('content-type');
if (!contentType || contentType.indexOf('application/json') === -1) {

try {
return await res.json();
} catch (e) {
throw new HttpError(await res.text(), {
code: res.statusCode
});
}
return res.json();
})
.catch(function(error) {
.catch(function (error) {
if (error instanceof HttpError) {
throw error;
}
Expand Down

0 comments on commit 5de7be0

Please sign in to comment.