Uncaught error on mutation
Hi!
I'm trying to catch rejected promise in mutation (onError) . But I get Uncaught error in promise.
Unless I wrap
await handleCreateGeneral(formData)
with try/catch.
So the question is: Isn't onError supposed to catch that error? The toast is triggered but the error is propagated further
Thanks


3 Replies
xenial-black•15mo ago
with
mutateAsync
you need to catch errors, with mutate
you don't. if you don't need the promise returned from mutateAsync
- don't use it.xenial-black•15mo ago
Mastering Mutations in React Query
Learn all about the concept of performing side effects on the server with React Query.
optimistic-goldOP•15mo ago
Great! Thanks a lot ! 👍