T
TanStack10mo ago
automatic-azure

working with validator and zod in Server Function

i was unable to get the error handling properly because i assumed the error would be thrown to the client in its original form. Poking around i found this parameter validateClient and it seems to let my code work, the zod error is thrown to the client, but I am getting a type error?
export const loginFn = createServerFn({ method: 'POST', validateClient: true })
.validator(loginSchema)
.handler(async (ctx: any) => {
// get the form data
const { email, password } = ctx.data;

const supabase = getSupabaseServerClient();

const { data, error } = await supabase.auth.signInWithPassword({
email,
password,
});
export const loginFn = createServerFn({ method: 'POST', validateClient: true })
.validator(loginSchema)
.handler(async (ctx: any) => {
// get the form data
const { email, password } = ctx.data;

const supabase = getSupabaseServerClient();

const { data, error } = await supabase.auth.signInWithPassword({
email,
password,
});
Am I doing something wrong?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?