mutation.isSuccess not working

I have a submit function that when called, I want to do a mutation. If a successfull mutation, I want to do some action and if error I want to do a different action. My code currently is not catching the mutation.isSuccess even though there are no errors.
const submit = async () => {
await mutation.mutateAsync({
promptId: "123",
content: entryText,
});
if (mutation.isSuccess) {
setSuccess(true);
} else if (mutation.isError) {
setSuccess(false);
}
};
const submit = async () => {
await mutation.mutateAsync({
promptId: "123",
content: entryText,
});
if (mutation.isSuccess) {
setSuccess(true);
} else if (mutation.isError) {
setSuccess(false);
}
};
1 Reply
Ben
Ben2y ago
The if (!data) return would just catch if you fetched a table that didn't have any data in it yet for example
Want results from more Discord servers?
Add your server