isJsonResponse helper
This commit is contained in:
parent
bb6c194eab
commit
3ec0b7fb5d
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue