Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
#261 - processResponse support blob & Co
Browse files Browse the repository at this point in the history
- if the content-type is "application/json" or "text/plain" behavior will not change.
- all other cases will return whole response object.
  • Loading branch information
cbek authored and fabien0102 committed May 4, 2020
1 parent 1e45084 commit b258d7b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/util/processResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@ export const processResponse = async (response: Response) => {
responseError: true,
};
}
} else if ((response.headers.get("content-type") || "").includes("text/plain")) {
try {
return {
data: await response.text(),
responseError: false,
};
} catch (e) {
return {
data: e.message,
responseError: true,
};
}
} else {
return {
data: await response.text(),
data: response,
responseError: false,
};
}
Expand Down

0 comments on commit b258d7b

Please sign in to comment.