useQuery (with refetch) or useMutation for hitting a validation api? #7627
Unanswered
Laurence-NZ
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Approach 3:
🤷♂️ |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I have a form input which takes a license key and a button which fires a POST request to validate the key.
I have found a few different approaches online... I would really appreciate some advice on best practices!
Approach One - useQuery
Approach Two - useMutation
Mutate is easier but the name implies a change which is not happening. It also cannot be aborted as easily by passing signal. I would like to pop a valid/invalid toast when the mutation completes.
EDIT: Also would like to do other things which react query is good for, such as showing loading spinner or utilizing the built in error handling for determining if an error occurred
Beta Was this translation helpful? Give feedback.
All reactions