@cpzxrobot/sdk 1.3.131 → 1.3.132
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 +3 -2
- package/package.json +1 -1
- package/web_platform.ts +3 -2
package/dist/web_platform.js
CHANGED
|
@@ -194,10 +194,11 @@ class WebPlatform {
|
|
|
194
194
|
return { data: yield response.json() };
|
|
195
195
|
}),
|
|
196
196
|
post: (url, data, config) => __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
const isFormData = data instanceof FormData;
|
|
197
198
|
const response = yield this.fetchWithAuth(url, {
|
|
198
199
|
method: 'POST',
|
|
199
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
|
|
200
|
-
body: JSON.stringify(data)
|
|
200
|
+
headers: isFormData ? config === null || config === void 0 ? void 0 : config.headers : Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
|
|
201
|
+
body: isFormData ? data : JSON.stringify(data)
|
|
201
202
|
});
|
|
202
203
|
return { data: yield response.json() };
|
|
203
204
|
}),
|
package/package.json
CHANGED
package/web_platform.ts
CHANGED
|
@@ -206,13 +206,14 @@ export class WebPlatform implements PlatformInterface {
|
|
|
206
206
|
return { data: await response.json() };
|
|
207
207
|
},
|
|
208
208
|
post: async (url: string, data?: any, config?: any) => {
|
|
209
|
+
const isFormData = data instanceof FormData;
|
|
209
210
|
const response = await this.fetchWithAuth(url, {
|
|
210
211
|
method: 'POST',
|
|
211
|
-
headers: {
|
|
212
|
+
headers: isFormData ? config?.headers : {
|
|
212
213
|
'Content-Type': 'application/json',
|
|
213
214
|
...config?.headers
|
|
214
215
|
},
|
|
215
|
-
body: JSON.stringify(data)
|
|
216
|
+
body: isFormData ? data : JSON.stringify(data)
|
|
216
217
|
});
|
|
217
218
|
return { data: await response.json() };
|
|
218
219
|
},
|