How to handle Query Errors on client side (show toast on 401)
Hey ! Hope you're doing well ! I wanted to know if someone can explain to me how to handle errors on the client (using Next.js).
I need to handle UNAUTHENTICATED error on client because when a user tries to access a resource I want to display a feedback toast.
Thanks 🙏
1 Reply
Hey, I have had the same issue and what you looking for is creating a link https://trpc.io/docs/client/links#creating-a-custom-link.
Links Overview | tRPC
Links enable you to customize the flow of data between the tRPC Client and Server. A link should do only one thing, which can be either a self-contained modification to a tRPC operation (query, mutation, or subscription) or a side-effect based on the operation (such as logging).