Tom
Tom
HHono
Created by Tom on 12/20/2024 in #help
RPC + React Query Mutations
but yes this works as expected now, thank you for helping! still amazed how little this sort of thing is documented especially in the RPC section of the docs
32 replies
HHono
Created by Tom on 12/20/2024 in #help
RPC + React Query Mutations
ok so i found in backend, if i do this without the return before it:
c.json(
{
status: "error",
errors: [
{
path: "email",
message: "Email address does not exist",
},
],
},
400,
);
c.json(
{
status: "error",
errors: [
{
path: "email",
message: "Email address does not exist",
},
],
},
400,
);
our data in onSuccess is correct, but ofc we need to return c.json as we need to exit out early from the endpoint
32 replies
HHono
Created by Tom on 12/20/2024 in #help
RPC + React Query Mutations
can you throw with returning the 400 res?
32 replies
HHono
Created by Tom on 12/20/2024 in #help
RPC + React Query Mutations
im just surprised nobody else has had this issue
32 replies
HHono
Created by Tom on 12/20/2024 in #help
RPC + React Query Mutations
so if i throw:
mutationFn: async (data) => {
const res = await $post({ json: data });

if (!res.ok) throw new Error(res.statusText);

return res.json();
},
onSuccess: (data) => {
console.log(data);
},
onError: (error) => {
return console.log(error);
},
mutationFn: async (data) => {
const res = await $post({ json: data });

if (!res.ok) throw new Error(res.statusText);

return res.json();
},
onSuccess: (data) => {
console.log(data);
},
onError: (error) => {
return console.log(error);
},
i still have the same issue with the inclusion of a onError
32 replies
HHono
Created by Tom on 12/20/2024 in #help
RPC + React Query Mutations
eventually haha
32 replies
HHono
Created by Tom on 12/20/2024 in #help
RPC + React Query Mutations
yes this is what it looks like @ambergristle @NaughtyShiba :
const app = new Hono()
.post(
"/signin",
zValidator("json", signInRequestSchema, (result, c) => {
if (!result.success) {
return c.json(
{
success: false,
errors: errorBag.generateErrors(result.error.errors),
},
400,
);
}
}),
async (c) => {
const existingUser = await db.query.usersTable.findFirst({
where: eq(usersTable.email, c.req.valid("json").email),
});

if (!existingUser) {
return c.json(
{
success:false,
errors: [
{
path: "email",
message: "Email address does not exist",
},
],
},
400,
);
}

// More work

return c.json({
success: true,
data: {
user: {}
},
});
},
)
const app = new Hono()
.post(
"/signin",
zValidator("json", signInRequestSchema, (result, c) => {
if (!result.success) {
return c.json(
{
success: false,
errors: errorBag.generateErrors(result.error.errors),
},
400,
);
}
}),
async (c) => {
const existingUser = await db.query.usersTable.findFirst({
where: eq(usersTable.email, c.req.valid("json").email),
});

if (!existingUser) {
return c.json(
{
success:false,
errors: [
{
path: "email",
message: "Email address does not exist",
},
],
},
400,
);
}

// More work

return c.json({
success: true,
data: {
user: {}
},
});
},
)
32 replies
DTDrizzle Team
Created by Wesley on 3/2/2024 in #help
Issue using Ecosystem Guide - Use Drizzle ORM with Bun
+1 I have the same issue when using push also
2 replies