1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

isJsonResponse helper

This commit is contained in:
Kyle Spearrin
2019-04-10 15:39:36 -04:00
parent bb6c194eab
commit 3ec0b7fb5d

View File

@@ -166,8 +166,7 @@ export class ApiService implements ApiServiceAbstraction {
})); }));
let responseJson: any = null; let responseJson: any = null;
const typeHeader = response.headers.get('content-type'); if (this.isJsonResponse(response)) {
if (typeHeader != null && typeHeader.indexOf('application/json') > -1) {
responseJson = await response.json(); responseJson = await response.json();
} }
@@ -932,8 +931,7 @@ export class ApiService implements ApiServiceAbstraction {
} }
let responseJson: any = null; let responseJson: any = null;
const typeHeader = response.headers.get('content-type'); if (this.isJsonResponse(response)) {
if (typeHeader != null && typeHeader.indexOf('application/json') > -1) {
responseJson = await response.json(); responseJson = await response.json();
} }
@@ -1001,4 +999,9 @@ export class ApiService implements ApiServiceAbstraction {
} }
return base; return base;
} }
private isJsonResponse(response: Response): boolean {
const typeHeader = response.headers.get('content-type');
return typeHeader != null && typeHeader.indexOf('application/json') > -1;
}
} }