how to handle tRPC errors with mutationAsync on my react frontend?
im trying to convert this component to use tRPC mutation https://pastebin.com/4sJKCULW
here is what I have so far
https://pastebin.com/6Hph40Ur
this is the backend route
I am not getting consistent errors, for example in the screenshots u can see a prisma unique constraint and a zod error from the backend, they both have different structures unfortunately
to get the message from the zod, I have to JSON.parse and then do something like message[0].message which doesnt seem intuitive
so how would I handle errors in my try catch ? also what type do I give the error block?
also while im here, how do i get the zod validation from backend to do frontend validation as well before sending fetch?
and also doing
any tips appreciated in converting this very simple component, thanks
here is what I have so far
https://pastebin.com/6Hph40Ur
this is the backend route
I am not getting consistent errors, for example in the screenshots u can see a prisma unique constraint and a zod error from the backend, they both have different structures unfortunately
to get the message from the zod, I have to JSON.parse and then do something like message[0].message which doesnt seem intuitive
so how would I handle errors in my try catch ? also what type do I give the error block?
also while im here, how do i get the zod validation from backend to do frontend validation as well before sending fetch?
and also doing
const data = await res feels wrong to meany tips appreciated in converting this very simple component, thanks


Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
