@cpzxrobot/sdk 1.3.13 → 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.
@@ -107,7 +107,7 @@ class UserGateway extends Object {
107
107
  return {
108
108
  add: async (id) => {
109
109
  var axios = await this.context.ready;
110
- return axios.post(`/api/v2/user/${id}/sign/add`);
110
+ return axios.upload(`/api/v2/user/${id}/sign/add`);
111
111
  },
112
112
  get: async (id) => {
113
113
  var axios = await this.context.ready;
@@ -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
- return { data: await response.json() };
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.13",
3
+ "version": "1.3.15",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/user_gateway.ts CHANGED
@@ -131,7 +131,7 @@ export class UserGateway extends Object {
131
131
  return {
132
132
  add: async (id: number) => {
133
133
  var axios = await this.context.ready;
134
- return axios.post(`/api/v2/user/${id}/sign/add`);
134
+ return axios.upload(`/api/v2/user/${id}/sign/add`);
135
135
  },
136
136
  get: async (id: number) => {
137
137
  var axios = await this.context.ready;
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
- return { data: await response.json() };
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, {