useMutation onSuccess running before mutation function completes #2584
Unanswered
alexscott812
asked this question in
Q&A
Replies: 1 comment
-
Your mutation function doesn’t return anything:
notice the curly brackets, no return statement ;) you want:
or just
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I'm currently working on migrating my application to React Query and am loving it so far, but I am having some weird behavior from useMutation's onSuccess function and I cannot seem to figure out why. My mutation function takes in data to POST and a function that returns an access token (or if access token is invalid, it fetches a new access token with refresh token and returns the new access token):
My mutation is below:
The onSuccess function fires after the tokenFn() api call but before the POST review api call. Logs from server are below (the second line item comes from refetchQueries in onSuccess):
Is it not possible to have a mutation with two promises like the function above? How can I make the onSuccess wait for the whole function to complete? Any help or suggestions would be greatly appreciated.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions