benfah
benfah
TtRPC
Created by benfah on 11/14/2024 in #❓-help
tRPC mutation finishes early
Hi everybody, I'm currently trying to use a tRPC mutation I wrote to log in to supabase. After some trial and error I found out that my defined mutation somehow finishes early, meaning it doesn't wait for any awaits to finish and also does not respect the output of the function, which means the body of the tRPC mutation is always empty.
export const authRouter = createTRPCRouter({
login: publicProcedure.input(loginSchema).mutation(async ({ ctx, input }) => {
await sleep(10000); //that was added in to see if the request takes 10s, which it doesn't
const client = ctx.supabase;
const { error, data } = await client.auth.signInWithPassword({
email: input.email,
password: input.password,
});
if (error)
throw new TRPCError({
code: "UNAUTHORIZED",
cause: error,
message: "Not authorized.",
});
return data;
}),
});
export const authRouter = createTRPCRouter({
login: publicProcedure.input(loginSchema).mutation(async ({ ctx, input }) => {
await sleep(10000); //that was added in to see if the request takes 10s, which it doesn't
const client = ctx.supabase;
const { error, data } = await client.auth.signInWithPassword({
email: input.email,
password: input.password,
});
if (error)
throw new TRPCError({
code: "UNAUTHORIZED",
cause: error,
message: "Not authorized.",
});
return data;
}),
});
Does anyone know what I can do to make the mutation await the calls? If anyone needs some other information just let me know! Thanks!
1 replies