@emeryld/rrroutes-client 2.2.18 → 2.2.19
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.cjs +10 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10 -7
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.fetch.d.ts +4 -2
- package/dist/routesV3.client.types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -46,16 +46,19 @@ module.exports = __toCommonJS(index_exports);
|
|
|
46
46
|
|
|
47
47
|
// src/routesV3.client.fetch.ts
|
|
48
48
|
var HttpError = class extends Error {
|
|
49
|
-
constructor(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
constructor({
|
|
50
|
+
res,
|
|
51
|
+
url,
|
|
52
|
+
body: { message }
|
|
53
|
+
}) {
|
|
54
|
+
super(`[${res.status}] ${res.statusText}${message ? ` - ${message}` : ""}`);
|
|
53
55
|
this.name = "HttpError";
|
|
54
56
|
this.status = res.status;
|
|
55
57
|
this.statusText = res.statusText;
|
|
56
58
|
this.url = url;
|
|
57
|
-
this.body =
|
|
59
|
+
this.body = { message };
|
|
58
60
|
this.headers = res.headers ? Object.fromEntries(res.headers.entries()) : {};
|
|
61
|
+
console.log("Created HttpError:", this);
|
|
59
62
|
}
|
|
60
63
|
};
|
|
61
64
|
var defaultFetcher = async (req) => {
|
|
@@ -70,7 +73,7 @@ var defaultFetcher = async (req) => {
|
|
|
70
73
|
headers,
|
|
71
74
|
body: isFormData ? req.body : req.body == null ? void 0 : JSON.stringify(req.body)
|
|
72
75
|
});
|
|
73
|
-
const text = await res.
|
|
76
|
+
const text = await res.json();
|
|
74
77
|
if (!res.ok) {
|
|
75
78
|
throw new HttpError({
|
|
76
79
|
res,
|
|
@@ -80,7 +83,7 @@ var defaultFetcher = async (req) => {
|
|
|
80
83
|
}
|
|
81
84
|
try {
|
|
82
85
|
return {
|
|
83
|
-
data:
|
|
86
|
+
data: text,
|
|
84
87
|
headers: res.headers ? Object.fromEntries(res.headers.entries()) : {},
|
|
85
88
|
status: res.status
|
|
86
89
|
};
|