mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
Don't try and parse a json response if one is not received (#3574)
This commit is contained in:
@@ -2323,7 +2323,9 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
requestInit.headers = headers;
|
requestInit.headers = headers;
|
||||||
const response = await this.fetch(new Request(requestUrl, requestInit));
|
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();
|
const responseJson = await response.json();
|
||||||
return responseJson;
|
return responseJson;
|
||||||
} else if (response.status !== 200) {
|
} else if (response.status !== 200) {
|
||||||
|
|||||||
Reference in New Issue
Block a user