How to handle error from useMutation
Hi, i have this function that updates the post
And i created this hook
And then i'm using a try catch block with mutate, but it's not catching the error
1 Reply
foreign-sapphire•3y ago
There's no need to throw in onError. Also, mutate catches errors internally. You can use onError there or use mutateAsync : https://tkdodo.eu/blog/mastering-mutations-in-react-query#mutate-or-mutateasync
Mastering Mutations in React Query
Learn all about the concept of performing side effects on the server with React Query.