Don't try and parse a json response if one is not received (#3574)

This commit is contained in:
Addison Beck 2022-09-21 09:40:23 -04:00 committed by GitHub
parent 25caeaa26f
commit f72ef2dce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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) {