@cpzxrobot/sdk 1.3.14 → 1.3.15
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.
- package/dist/web_platform.js +8 -1
- package/package.json +1 -1
- package/web_platform.ts +6 -1
package/dist/web_platform.js
CHANGED
|
@@ -109,12 +109,19 @@ class WebPlatform {
|
|
|
109
109
|
var instance = this;
|
|
110
110
|
return {
|
|
111
111
|
get: async (url, config) => {
|
|
112
|
+
var _a;
|
|
112
113
|
url = instance.processQueryParams(url, config);
|
|
113
114
|
const response = await this.fetchWithAuth(url, {
|
|
114
115
|
method: 'GET',
|
|
115
116
|
headers: config === null || config === void 0 ? void 0 : config.headers
|
|
116
117
|
});
|
|
117
|
-
|
|
118
|
+
//test content-type, if it is json, then parse it
|
|
119
|
+
if ((_a = response.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
|
|
120
|
+
return { data: await response.json() };
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
return response.blob();
|
|
124
|
+
}
|
|
118
125
|
},
|
|
119
126
|
post: async (url, data, config) => {
|
|
120
127
|
const response = await this.fetchWithAuth(url, {
|
package/package.json
CHANGED
package/web_platform.ts
CHANGED
|
@@ -122,7 +122,12 @@ export class WebPlatform implements PlatformInterface {
|
|
|
122
122
|
method: 'GET',
|
|
123
123
|
headers: config?.headers
|
|
124
124
|
});
|
|
125
|
-
|
|
125
|
+
//test content-type, if it is json, then parse it
|
|
126
|
+
if (response.headers.get('Content-Type')?.includes('application/json')) {
|
|
127
|
+
return { data: await response.json() };
|
|
128
|
+
}else {
|
|
129
|
+
return response.blob();
|
|
130
|
+
}
|
|
126
131
|
},
|
|
127
132
|
post: async (url: string, data?: any, config?: any) => {
|
|
128
133
|
const response = await this.fetchWithAuth(url, {
|