shred-api-client 1.1.13 → 1.1.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.
@@ -11,7 +11,7 @@ class PromptAPI {
11
11
  }
12
12
  async getPrompt(context) {
13
13
  const endpointInfo = Prompt_schema_1.PromptEndpoints.GetPrompt;
14
- const data = await this.clientHTTP.makeRequest(endpointInfo.uri, endpointInfo.method, context);
14
+ const data = await this.clientHTTP.makeRequest(endpointInfo.uri, endpointInfo.method, null, context);
15
15
  return data;
16
16
  }
17
17
  }
@@ -1,4 +1,4 @@
1
1
  import Context from "./../model/Context";
2
2
  export default class HTTPClient {
3
- makeRequest(uri: string, method: string, data: any, context?: Context | null, useLegacyApi?: boolean): Promise<any>;
3
+ makeRequest(uri: string, method: string, data?: any, context?: Context | null, useLegacyApi?: boolean): Promise<any>;
4
4
  }
@@ -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,16 +28,20 @@ class HTTPClient {
27
28
  ? "application/x-www-form-urlencoded"
28
29
  : "application/json",
29
30
  },
30
- data: method === "GET" ? null : data,
31
+ data,
31
32
  };
32
33
  try {
33
- console.log("Making HTTP Request", config);
34
34
  const response = await (0, axios_1.default)(config);
35
35
  return response.data;
36
36
  }
37
37
  catch (error) {
38
- console.error("Error making HTTP request:", error);
39
- throw error;
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
+ }
40
45
  }
41
46
  }
42
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",