attlaz-client 1.13.6 → 1.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,4 +7,21 @@ export class HttpClientResponse {
|
|
|
7
7
|
this.status = status;
|
|
8
8
|
this.statusText = statusText;
|
|
9
9
|
}
|
|
10
|
+
getContentType() {
|
|
11
|
+
let contentType = this.headers['content-type'];
|
|
12
|
+
if (contentType === null || contentType === undefined) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (Symbol.iterator in Object(contentType)) {
|
|
16
|
+
// eslint-disable-next-line prefer-destructuring
|
|
17
|
+
contentType = contentType[0];
|
|
18
|
+
}
|
|
19
|
+
if (contentType === null || contentType === undefined) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (contentType.includes('application/json')) {
|
|
23
|
+
return 'json';
|
|
24
|
+
}
|
|
25
|
+
throw new Error('Unknown content type `' + contentType + '`');
|
|
26
|
+
}
|
|
10
27
|
}
|