abbot-http-client 0.0.55 → 0.0.57

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/index.cjs CHANGED
@@ -296,20 +296,18 @@ var AbbotHttp = class extends AxiosBase {
296
296
  axios2.interceptors.response.use(
297
297
  async (response) => {
298
298
  const res = { ...response };
299
+ const contentType = response.headers["content-type"];
299
300
  if (option?.isDownload) {
300
301
  const contentTypes = ["application/json", "text/plain"];
301
- if (contentTypes.includes(response.headers["content-type"])) {
302
- const result = response.data instanceof Blob ? await response.data.text() : response.data;
303
- res.data = cryp.decrypt(result);
304
- if (this.config.devMode) {
305
- axios2.log.logResponse(res.data);
306
- }
302
+ if (contentTypes.includes(contentType) && response.data instanceof Blob) {
303
+ res.data = cryp.decrypt(await response.data.text());
304
+ } else {
305
+ res.data = response.data;
307
306
  }
307
+ } else {
308
+ res.data = cryp.decrypt(response.data);
308
309
  }
309
- res.data = cryp.decrypt(response.data);
310
- if (this.config.devMode) {
311
- axios2.log.logResponse(res.data);
312
- }
310
+ if (this.config.devMode) axios2.log.logResponse(res.data);
313
311
  return res;
314
312
  },
315
313
  (error) => {
@@ -499,7 +497,7 @@ var AbbotHttp = class extends AxiosBase {
499
497
  }
500
498
  response = await axios2.post(url, formData);
501
499
  }
502
- return response;
500
+ return response.data;
503
501
  }
504
502
  };
505
503
 
package/dist/index.d.cts CHANGED
@@ -96,13 +96,13 @@ declare class AbbotHttp extends AxiosBase {
96
96
  private handleError;
97
97
  post<T>(url: string, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
98
98
  get<T>(url: string, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
99
- download(url: string, param?: Record<string, any> | null,
99
+ download<R>(url: string, param?: Record<string, any> | null,
100
100
  /**
101
101
  * isDownload is set to "true" mandatory
102
102
  *
103
103
  * responseType is set to "blob" mandatory
104
104
  */
105
- option?: Partial<MethodOption>): Promise<AxiosResponse>;
105
+ option?: Partial<MethodOption>): Promise<AxiosResponse<R>>;
106
106
  uploadFile<T>(url: string, file: File, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
107
107
  uploadFile<T>(url: string, file: File[], fileKeys: string[], param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
108
108
  }
package/dist/index.d.ts CHANGED
@@ -96,13 +96,13 @@ declare class AbbotHttp extends AxiosBase {
96
96
  private handleError;
97
97
  post<T>(url: string, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
98
98
  get<T>(url: string, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
99
- download(url: string, param?: Record<string, any> | null,
99
+ download<R>(url: string, param?: Record<string, any> | null,
100
100
  /**
101
101
  * isDownload is set to "true" mandatory
102
102
  *
103
103
  * responseType is set to "blob" mandatory
104
104
  */
105
- option?: Partial<MethodOption>): Promise<AxiosResponse>;
105
+ option?: Partial<MethodOption>): Promise<AxiosResponse<R>>;
106
106
  uploadFile<T>(url: string, file: File, param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
107
107
  uploadFile<T>(url: string, file: File[], fileKeys: string[], param?: Record<string, any> | null, option?: Partial<MethodOption>): Promise<AbbotResponse<T>>;
108
108
  }
package/dist/index.js CHANGED
@@ -249,20 +249,18 @@ var AbbotHttp = class extends AxiosBase {
249
249
  axios2.interceptors.response.use(
250
250
  async (response) => {
251
251
  const res = { ...response };
252
+ const contentType = response.headers["content-type"];
252
253
  if (option?.isDownload) {
253
254
  const contentTypes = ["application/json", "text/plain"];
254
- if (contentTypes.includes(response.headers["content-type"])) {
255
- const result = response.data instanceof Blob ? await response.data.text() : response.data;
256
- res.data = cryp.decrypt(result);
257
- if (this.config.devMode) {
258
- axios2.log.logResponse(res.data);
259
- }
255
+ if (contentTypes.includes(contentType) && response.data instanceof Blob) {
256
+ res.data = cryp.decrypt(await response.data.text());
257
+ } else {
258
+ res.data = response.data;
260
259
  }
260
+ } else {
261
+ res.data = cryp.decrypt(response.data);
261
262
  }
262
- res.data = cryp.decrypt(response.data);
263
- if (this.config.devMode) {
264
- axios2.log.logResponse(res.data);
265
- }
263
+ if (this.config.devMode) axios2.log.logResponse(res.data);
266
264
  return res;
267
265
  },
268
266
  (error) => {
@@ -452,7 +450,7 @@ var AbbotHttp = class extends AxiosBase {
452
450
  }
453
451
  response = await axios2.post(url, formData);
454
452
  }
455
- return response;
453
+ return response.data;
456
454
  }
457
455
  };
458
456
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abbot-http-client",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "description": "This package helps Abbot team to handle all the axios requests.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",