shred-api-client 1.0.6 → 1.0.7

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,5 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
3
7
  const HOSTS = {
4
8
  prod: "https://api.shredmedia.co",
5
9
  staging: "https://api-staging.shredmedia.co",
@@ -10,21 +14,19 @@ class HTTPClient {
10
14
  this.host = HOSTS[env] || HOSTS.staging;
11
15
  }
12
16
  async makeRequest(uri, method, data, context) {
13
- const headers = new Headers();
14
- headers.append("Authorization", `Bearer ${context.token}`);
15
- headers.append("X-Request-ID", context.requestId);
16
17
  const config = {
17
18
  method: method,
18
- headers: headers,
19
- body: method === "GET" ? null : JSON.stringify(data),
19
+ url: this.host + uri,
20
+ headers: {
21
+ Authorization: `Bearer ${context.token}`,
22
+ "X-Request-ID": context.requestId,
23
+ "Content-Type": "application/json",
24
+ },
25
+ data: method === "GET" ? null : data,
20
26
  };
21
27
  try {
22
- const endpoint = this.host + uri;
23
- const response = await fetch(endpoint, config);
24
- if (!response.ok) {
25
- throw new Error(`HTTP error! status: ${response.status}`);
26
- }
27
- return await response.json();
28
+ const response = await (0, axios_1.default)(config);
29
+ return response.data;
28
30
  }
29
31
  catch (error) {
30
32
  console.error("Error making HTTP request:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shred-api-client",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "API Client for Shred",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",