Error Handling with next-safe-actions in React-Query: Errors Resolving as Data or Not Caught #226
Unanswered
AndonMitev
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is my server action:
And then this is how i use it in react_query
export default function useThrowErrorQuery() {
const query = useQuery({
queryKey: ['throw_error'],
queryFn: async () => await getTasks(),
});
console.log(query);
}
So it happens this line here
throw new ActionError('Failed to fetch tasks');
to be resolved underquery.data
instead of query.error, i've tried with addingthrowServerError: true
which indeed throws error but then is not reaching react-query at all, and also triedonError callback like this:
which happens to fit the error in failureReason:
But also throwing pretty nasty error on the server
Is it possible somehow to:
Throw the error and handle it as expected with react-query?
Beta Was this translation helpful? Give feedback.
All reactions