Unhandled runtime error using useMutation hook
I am using useMutation hook to update my database records. I thought that
useMutation hook handles the error with onError method, but instead I get unhandled runtime error, here is my code:

5 Replies
plain-purple•4y ago
you're not showing the whole code. are you calling
mutate or mutateAsync ?flat-fuchsiaOP•4y ago
Sorry, yes I'm calling it with
mutate:
plain-purple•4y ago
ah, I see the error., you're not returning the promise from the mutation function:
flat-fuchsiaOP•4y ago
Thanks, it works now!
Can I ask, why it was throwing error, I know I wasn't returning the function, but it was still running?
plain-purple•4y ago
because mutate can only catch errors from the promise it receives