tRPC mutation onError handler error type for shared logic
I have two mutations on my frontend that should handle the response in the same way. So I extract the onError function so these two mutations can re-use the logic but I have a problem on how to type the error so the in function handling is pleased with typescript and the onError handler is also pleased.
I have tried like
error: TRPCClientError<AppRouter>
this does satisfy the function and internal of it but doesn't comply with the onError handlers onError: onApiError
2 Replies