Skip to content

Commit

Permalink
chore: fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekacru committed Feb 8, 2025
1 parent b7c469a commit 075d174
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/better-fetch/src/test/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ describe("create-fetch-type-test", () => {
baseURL: "http://localhost:4001",
schema: createSchema(schema),
customFetchImpl: async (url, req) => {
return new Response();
return new Response(JSON.stringify({ message: "hello" }));
},
});
$fetch2("/", {
Expand Down
5 changes: 5 additions & 0 deletions packages/better-fetch/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ export function getBody(options?: BetterFetchOption) {
}
const headers = new Headers(options?.headers);
if (isJSONSerializable(options.body) && !headers.has("content-type")) {
for (const [key, value] of Object.entries(options?.body)) {
if (value instanceof Date) {
options.body[key] = value.toISOString();
}
}
return JSON.stringify(options.body);
}

Expand Down

0 comments on commit 075d174

Please sign in to comment.