@firtoz/hono-fetcher 2.4.0 → 2.4.1
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/package.json +1 -1
- package/src/honoFetcher.ts +12 -2
package/package.json
CHANGED
package/src/honoFetcher.ts
CHANGED
|
@@ -66,6 +66,16 @@ function appendQueryString(
|
|
|
66
66
|
return `${url}${separator}${serialized}`;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* `RequestInit` fields that honoFetcher sets must not be overwritten by spreading `...init` last.
|
|
71
|
+
*/
|
|
72
|
+
function restOfRequestInit(
|
|
73
|
+
init: RequestInit,
|
|
74
|
+
): Omit<RequestInit, "headers" | "body" | "method"> {
|
|
75
|
+
const { headers: _h, body: _b, method: _m, ...rest } = init;
|
|
76
|
+
return rest;
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
type FetcherParams<SchemaPath extends string> =
|
|
70
80
|
HasPathParams<SchemaPath> extends true
|
|
71
81
|
? {
|
|
@@ -209,10 +219,10 @@ const createMethodFetcher = <T extends Hono, M extends HttpMethod>(
|
|
|
209
219
|
|
|
210
220
|
try {
|
|
211
221
|
return await fetcher(finalUrl, {
|
|
222
|
+
...restOfRequestInit(init),
|
|
212
223
|
method: method.toUpperCase(),
|
|
213
224
|
headers: newHeaders,
|
|
214
225
|
...(body ? { body } : {}),
|
|
215
|
-
...init,
|
|
216
226
|
});
|
|
217
227
|
} catch (error) {
|
|
218
228
|
console.error(`Error ${method}ing`, error);
|
|
@@ -248,9 +258,9 @@ const createWebSocketFetcher = <T extends Hono>(
|
|
|
248
258
|
|
|
249
259
|
try {
|
|
250
260
|
const response = await fetcher(finalUrl, {
|
|
261
|
+
...restOfRequestInit(init),
|
|
251
262
|
method: "GET",
|
|
252
263
|
headers: newHeaders,
|
|
253
|
-
...init,
|
|
254
264
|
});
|
|
255
265
|
|
|
256
266
|
// Auto-accept the WebSocket if configured (default: true)
|