@sfutureapps/db-sdk 0.3.7 → 0.3.8

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.js CHANGED
@@ -40,18 +40,14 @@ var HttpClient = class {
40
40
  if (this.apiKey) headers["x-api-key"] = this.apiKey;
41
41
  const token = this.accessToken?.();
42
42
  if (token) headers["Authorization"] = `Bearer ${token}`;
43
- const url = `${this.baseUrl}${path}`;
44
- const res = await window.fetch(url, {
43
+ const res = await fetch(`${this.baseUrl}${path}`, {
45
44
  method: "POST",
46
45
  headers,
47
46
  body: JSON.stringify(body)
48
47
  });
49
48
  const text = await res.text();
50
49
  if (!res.ok) {
51
- return {
52
- data: null,
53
- error: { status: res.status, message: text || res.statusText }
54
- };
50
+ return { data: null, error: { status: res.status, message: text || res.statusText } };
55
51
  }
56
52
  try {
57
53
  const json = JSON.parse(text || "{}");
@@ -62,10 +58,7 @@ var HttpClient = class {
62
58
  error: json.error ?? null
63
59
  };
64
60
  } catch {
65
- return {
66
- data: null,
67
- error: { message: "Invalid JSON response", details: text }
68
- };
61
+ return { data: null, error: { status: res.status, message: "Invalid JSON response", details: text } };
69
62
  }
70
63
  }
71
64
  };
package/dist/index.mjs CHANGED
@@ -14,18 +14,14 @@ var HttpClient = class {
14
14
  if (this.apiKey) headers["x-api-key"] = this.apiKey;
15
15
  const token = this.accessToken?.();
16
16
  if (token) headers["Authorization"] = `Bearer ${token}`;
17
- const url = `${this.baseUrl}${path}`;
18
- const res = await window.fetch(url, {
17
+ const res = await fetch(`${this.baseUrl}${path}`, {
19
18
  method: "POST",
20
19
  headers,
21
20
  body: JSON.stringify(body)
22
21
  });
23
22
  const text = await res.text();
24
23
  if (!res.ok) {
25
- return {
26
- data: null,
27
- error: { status: res.status, message: text || res.statusText }
28
- };
24
+ return { data: null, error: { status: res.status, message: text || res.statusText } };
29
25
  }
30
26
  try {
31
27
  const json = JSON.parse(text || "{}");
@@ -36,10 +32,7 @@ var HttpClient = class {
36
32
  error: json.error ?? null
37
33
  };
38
34
  } catch {
39
- return {
40
- data: null,
41
- error: { message: "Invalid JSON response", details: text }
42
- };
35
+ return { data: null, error: { status: res.status, message: "Invalid JSON response", details: text } };
43
36
  }
44
37
  }
45
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfutureapps/db-sdk",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "SfutureApps JS SDK for ThinkPHP DB Gateway (MySQL)",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs",