shred-api-client 1.1.14 → 1.1.16
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,4 +1,4 @@
|
|
|
1
1
|
import Context from "./../model/Context";
|
|
2
2
|
export default class HTTPClient {
|
|
3
|
-
makeRequest(uri: string, method: string, data
|
|
3
|
+
makeRequest(uri: string, method: string, data?: any, context?: Context | null, useLegacyApi?: boolean): Promise<any>;
|
|
4
4
|
}
|
package/dist/util/HTTPClient.js
CHANGED
|
@@ -14,6 +14,7 @@ const OLD_HOSTS = {
|
|
|
14
14
|
};
|
|
15
15
|
class HTTPClient {
|
|
16
16
|
async makeRequest(uri, method, data, context, useLegacyApi) {
|
|
17
|
+
var _a;
|
|
17
18
|
const env = (process.env.NEXT_PUBLIC_ENV || process.env.ENV);
|
|
18
19
|
const hostDict = useLegacyApi ? OLD_HOSTS : HOSTS;
|
|
19
20
|
const host = hostDict[env] || hostDict.staging;
|
|
@@ -27,15 +28,20 @@ class HTTPClient {
|
|
|
27
28
|
? "application/x-www-form-urlencoded"
|
|
28
29
|
: "application/json",
|
|
29
30
|
},
|
|
30
|
-
data
|
|
31
|
+
data,
|
|
31
32
|
};
|
|
32
33
|
try {
|
|
33
34
|
const response = await (0, axios_1.default)(config);
|
|
34
35
|
return response.data;
|
|
35
36
|
}
|
|
36
37
|
catch (error) {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
39
|
+
const axiosError = error;
|
|
40
|
+
throw ((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.data) || axiosError;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shred-api-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"description": "API Client for Shred",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"author": "Marcus Cartágenes",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"axios": "^1.
|
|
18
|
+
"axios": "^1.5.1",
|
|
19
19
|
"winston": "^3.13.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|