isJsonResponse helper

This commit is contained in:
Kyle Spearrin 2019-04-10 15:39:36 -04:00
parent bb6c194eab
commit 3ec0b7fb5d
1 changed files with 7 additions and 4 deletions

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;
}
} }