sazz
sazz
SIASapphire - Imagine a framework
Created by sazz on 9/2/2024 in #sapphire-support
Fetch not calling JSON.stringify for body objects.
i will take a look later today
14 replies
SIASapphire - Imagine a framework
Created by sazz on 9/2/2024 in #sapphire-support
Fetch not calling JSON.stringify for body objects.
hmmm wonder if it's being caused by something else then
14 replies
SIASapphire - Imagine a framework
Created by sazz on 9/2/2024 in #sapphire-support
Fetch not calling JSON.stringify for body objects.
made a repro sample, it's pretty much like this: lmk if u guys need more info, happy to provide
import { fetch } from "@sapphire/fetch";
import { z } from "zod";

const loginSchema = z.object({
email: z.string().email(),
password: z.string().min(8),
});

async function login(values: z.infer<typeof loginSchema>) {
try {
const response = await fetch(
`<api_url>/auth/login`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: values,
}
);

console.log(response)

return {
success: true,
};
} catch (error) {
console.error(error)
}
}

login({
password: "abc123"
})
import { fetch } from "@sapphire/fetch";
import { z } from "zod";

const loginSchema = z.object({
email: z.string().email(),
password: z.string().min(8),
});

async function login(values: z.infer<typeof loginSchema>) {
try {
const response = await fetch(
`<api_url>/auth/login`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: values,
}
);

console.log(response)

return {
success: true,
};
} catch (error) {
console.error(error)
}
}

login({
password: "abc123"
})
14 replies
SIASapphire - Imagine a framework
Created by sazz on 9/2/2024 in #sapphire-support
Fetch not calling JSON.stringify for body objects.
I think this just another case of JavaScript is being weird, and having some plain objects with different constructors than Object for some reason
14 replies
SIASapphire - Imagine a framework
Created by sazz on 9/2/2024 in #sapphire-support
Fetch not calling JSON.stringify for body objects.
can provide a code snippet too, i am just not on my computer rn
14 replies
SIASapphire - Imagine a framework
Created by sazz on 9/2/2024 in #sapphire-support
Fetch not calling JSON.stringify for body objects.
it's pretty much this { email: "[email protected]", password: "abc123" }. it comes from a zod z.infer of a schema
14 replies