1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

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

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