T
TanStack15mo ago
optimistic-gold

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
No description
No description
No description
3 Replies
xenial-black
xenial-black15mo 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
xenial-black15mo ago
Mastering Mutations in React Query
Learn all about the concept of performing side effects on the server with React Query.
optimistic-gold
optimistic-goldOP15mo ago
Great! Thanks a lot ! 👍

Did you find this page helpful?