@vasrefil/api-toolkit 1.4.0 → 1.4.2

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.
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RequestHelper = void 0;
4
+ const axios_1 = require("axios");
4
5
  class RequestHelper_ {
5
6
  get_error(error) {
6
- if (error instanceof Error) {
7
+ if (error instanceof axios_1.AxiosError) {
8
+ const err = error;
9
+ const url = err?.response?.config?.url || "url";
10
+ const data = err?.response?.data ? err.response.data : error;
11
+ // const resp = typeof(data) === 'object' ? {url, ...data} : data;
12
+ return data;
13
+ }
14
+ else if (error instanceof Error) {
7
15
  return error?.stack || error?.message;
8
16
  }
9
17
  else {
10
- const url = error?.response?.config?.url || "url";
11
- const data = error.response && error.response.data ? error.response.data : error;
12
- // const resp = typeof(data) === 'object' ? {url, ...data} : data;
13
- return data;
18
+ return error;
14
19
  }
15
20
  }
16
21
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vasrefil/api-toolkit",
3
3
  "description": "This is Vasrefil API toolkit",
4
- "version": "1.4.0",
4
+ "version": "1.4.2",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",