middleware
middleware copied to clipboard
Status code used in the third argument of zValidator is not inferred on the client side
I have the following code. When trying to handle branching on the client side based on res.status
, it always ends up being 200. Is there any documentation or solution regarding this issue?
const sampleRoute = new Hono().get(
'/sample',
zValidator(
'json',
z.object({
keyword: z.string().min(1),
}),
(result, c) => {
if (!result.success) {
return c.json({ error: 'error!' }, 400)
}
}
),
async (c) => {
return c.json({ data: 'data' }, 200)
}
)
in client