abbot-http-client 0.0.51 → 0.0.52

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
@@ -309,13 +309,12 @@ var AbbotHttp = class extends Axios {
309
309
  axios2.log.logResponse(res.data);
310
310
  }
311
311
  }
312
- return res;
313
312
  }
314
313
  res.data = cryp.decrypt(response.data);
315
314
  if (this.config.devMode) {
316
315
  axios2.log.logResponse(res.data);
317
316
  }
318
- return res.data;
317
+ return res;
319
318
  },
320
319
  (error) => {
321
320
  if (this.config.devMode) {
@@ -380,14 +379,17 @@ var AbbotHttp = class extends Axios {
380
379
  status: "error",
381
380
  code: 0,
382
381
  message: "No response received",
382
+ detail: "",
383
383
  data: null
384
384
  };
385
385
  if (error.code === "ECONNABORTED") {
386
386
  err.response.code = -1;
387
387
  err.response.message = "\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E43\u0E0A\u0E49\u0E40\u0E27\u0E25\u0E32\u0E19\u0E32\u0E40\u0E01\u0E34\u0E19\u0E44\u0E1B";
388
+ err.response.detail = "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E43\u0E2B\u0E21\u0E48\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07";
388
389
  } else if (error.code === "ERR_NETWORK") {
389
390
  err.response.code = -2;
390
391
  err.response.message = "\u0E01\u0E32\u0E23\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D\u0E2D\u0E34\u0E19\u0E40\u0E15\u0E2D\u0E23\u0E4C\u0E40\u0E19\u0E47\u0E15\u0E21\u0E35\u0E1B\u0E31\u0E0D\u0E2B\u0E32";
392
+ err.response.detail = "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E43\u0E2B\u0E21\u0E48\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07";
391
393
  }
392
394
  return Promise.reject(
393
395
  new import_axios2.AxiosError(
@@ -403,6 +405,7 @@ var AbbotHttp = class extends Axios {
403
405
  status: "error",
404
406
  code: 0,
405
407
  message: error.message,
408
+ detail: "",
406
409
  data: null
407
410
  };
408
411
  return Promise.reject(
@@ -418,13 +421,35 @@ var AbbotHttp = class extends Axios {
418
421
  }
419
422
  async post(url, param, option) {
420
423
  const axios2 = this.createAxiosInstance(option);
421
- const response = await axios2.post(url, param);
422
- return response;
424
+ return await axios2.post(url, param).then((e) => e.data).catch((err) => {
425
+ if (err.response) {
426
+ const res = err.response;
427
+ return res;
428
+ }
429
+ return {
430
+ code: 0,
431
+ detail: null,
432
+ message: "",
433
+ status: "error",
434
+ data: null
435
+ };
436
+ });
423
437
  }
424
438
  async get(url, option) {
425
439
  const axios2 = this.createAxiosInstance(option);
426
- const response = await axios2.get(url);
427
- return response;
440
+ return await axios2.get(url).then((e) => e.data).catch((err) => {
441
+ if (err.response) {
442
+ const res = err.response;
443
+ return res;
444
+ }
445
+ return {
446
+ code: 0,
447
+ detail: null,
448
+ message: "",
449
+ status: "error",
450
+ data: null
451
+ };
452
+ });
428
453
  }
429
454
  async download(url, param, option) {
430
455
  const axios2 = this.createAxiosInstance({
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ResponseType, AxiosResponse, AxiosInstance, AxiosError } from 'axios';
1
+ import { ResponseType, AxiosInstance, AxiosResponse, AxiosError } from 'axios';
2
2
 
3
3
  interface AbbotConfig {
4
4
  axios: {
@@ -51,7 +51,7 @@ interface MethodOption {
51
51
  isDownload: boolean;
52
52
  }
53
53
  interface AbbotResponse<T> {
54
- code: AxiosResponse["status"];
54
+ code: number;
55
55
  detail: string | null;
56
56
  message: string;
57
57
  status: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ResponseType, AxiosResponse, AxiosInstance, AxiosError } from 'axios';
1
+ import { ResponseType, AxiosInstance, AxiosResponse, AxiosError } from 'axios';
2
2
 
3
3
  interface AbbotConfig {
4
4
  axios: {
@@ -51,7 +51,7 @@ interface MethodOption {
51
51
  isDownload: boolean;
52
52
  }
53
53
  interface AbbotResponse<T> {
54
- code: AxiosResponse["status"];
54
+ code: number;
55
55
  detail: string | null;
56
56
  message: string;
57
57
  status: string;
package/dist/index.js CHANGED
@@ -263,13 +263,12 @@ var AbbotHttp = class extends Axios {
263
263
  axios2.log.logResponse(res.data);
264
264
  }
265
265
  }
266
- return res;
267
266
  }
268
267
  res.data = cryp.decrypt(response.data);
269
268
  if (this.config.devMode) {
270
269
  axios2.log.logResponse(res.data);
271
270
  }
272
- return res.data;
271
+ return res;
273
272
  },
274
273
  (error) => {
275
274
  if (this.config.devMode) {
@@ -334,14 +333,17 @@ var AbbotHttp = class extends Axios {
334
333
  status: "error",
335
334
  code: 0,
336
335
  message: "No response received",
336
+ detail: "",
337
337
  data: null
338
338
  };
339
339
  if (error.code === "ECONNABORTED") {
340
340
  err.response.code = -1;
341
341
  err.response.message = "\u0E01\u0E32\u0E23\u0E14\u0E33\u0E40\u0E19\u0E34\u0E19\u0E01\u0E32\u0E23\u0E43\u0E0A\u0E49\u0E40\u0E27\u0E25\u0E32\u0E19\u0E32\u0E40\u0E01\u0E34\u0E19\u0E44\u0E1B";
342
+ err.response.detail = "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E43\u0E2B\u0E21\u0E48\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07";
342
343
  } else if (error.code === "ERR_NETWORK") {
343
344
  err.response.code = -2;
344
345
  err.response.message = "\u0E01\u0E32\u0E23\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D\u0E2D\u0E34\u0E19\u0E40\u0E15\u0E2D\u0E23\u0E4C\u0E40\u0E19\u0E47\u0E15\u0E21\u0E35\u0E1B\u0E31\u0E0D\u0E2B\u0E32";
346
+ err.response.detail = "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E25\u0E2D\u0E07\u0E43\u0E2B\u0E21\u0E48\u0E2D\u0E35\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07";
345
347
  }
346
348
  return Promise.reject(
347
349
  new AxiosError(
@@ -357,6 +359,7 @@ var AbbotHttp = class extends Axios {
357
359
  status: "error",
358
360
  code: 0,
359
361
  message: error.message,
362
+ detail: "",
360
363
  data: null
361
364
  };
362
365
  return Promise.reject(
@@ -372,13 +375,35 @@ var AbbotHttp = class extends Axios {
372
375
  }
373
376
  async post(url, param, option) {
374
377
  const axios2 = this.createAxiosInstance(option);
375
- const response = await axios2.post(url, param);
376
- return response;
378
+ return await axios2.post(url, param).then((e) => e.data).catch((err) => {
379
+ if (err.response) {
380
+ const res = err.response;
381
+ return res;
382
+ }
383
+ return {
384
+ code: 0,
385
+ detail: null,
386
+ message: "",
387
+ status: "error",
388
+ data: null
389
+ };
390
+ });
377
391
  }
378
392
  async get(url, option) {
379
393
  const axios2 = this.createAxiosInstance(option);
380
- const response = await axios2.get(url);
381
- return response;
394
+ return await axios2.get(url).then((e) => e.data).catch((err) => {
395
+ if (err.response) {
396
+ const res = err.response;
397
+ return res;
398
+ }
399
+ return {
400
+ code: 0,
401
+ detail: null,
402
+ message: "",
403
+ status: "error",
404
+ data: null
405
+ };
406
+ });
382
407
  }
383
408
  async download(url, param, option) {
384
409
  const axios2 = this.createAxiosInstance({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abbot-http-client",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
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",