What is the difference between onSuccess and .then? #2651
-
I was wondering what the difference between these 2 approaches below are. My scenario is that I redirect to another page on successful mutation 200 OK, so i don't really need to do anything with the response data. Approach 1: Using
Approach 2: Using
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
there isn't really any. It's just that if you use if you look at how mutate is implemented - it's literally |
Beta Was this translation helpful? Give feedback.
there isn't really any. It's just that if you use
mutateAsync
, you have to catch errors yourselves, or you'll get an unhandled promise rejection. Most of the time, having access to the actual promise is not necessary - unless you want to fire off multiple things concurrently. So you can just call.mutate
and work with the callbacks.if you look at how mutate is implemented - it's literally
mutateAsync
with a.catch(noop)
attached and it doesn't return the promise, but keeps it to itself :)