Skip to content

Commit

Permalink
Don't try and parse a json response if one is not received (#3574)
Browse files Browse the repository at this point in the history
  • Loading branch information
addisonbeck committed Sep 21, 2022
1 parent 25caeaa commit f72ef2d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/common/src/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,9 @@ export class ApiService implements ApiServiceAbstraction {
requestInit.headers = headers;
const response = await this.fetch(new Request(requestUrl, requestInit));

if (hasResponse && response.status === 200) {
const responseType = response.headers.get("content-type");
const responseIsJson = responseType != null && responseType.indexOf("application/json") !== -1;
if (hasResponse && response.status === 200 && responseIsJson) {
const responseJson = await response.json();
return responseJson;
} else if (response.status !== 200) {
Expand Down

0 comments on commit f72ef2d

Please sign in to comment.