-
Currently, we do something like this: const { data, isFetching } = useQuery({
queryKey: ['billingInfo'],
queryFn: getBillingInfo,
onError: (error: GraphQLError) => {
reportError(error, {
while: 'fetching billing information',
});
}, With the const { data, error, isFetching, status } = useQuery({
queryKey: ['billingInfo'],
queryFn: getBillingInfo,
});
watch(status, (newStatus) => {
if (newStatus === 'error') {
reportError(error, {
while: 'fetching billing information',
});
}
}); Is there a cleaner way? Why are the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
here's what I would do:
then use it like this:
if its enough to include the QueryKey in the error reporting, its even easier:
but with |
Beta Was this translation helpful? Give feedback.
-
Just wanted to post the solution here. The missing key was to pass the custom client to the Vue plugin init, in app.use(VueQueryPlugin, {
queryClient: new QueryClient({
queryCache: new QueryCache({
onError: (error, query) => {
if (query.meta?.errorMessage) {
console.error('uh oh!', query.meta.errorMessage);
}
},
}),
}),
}); Works great! |
Beta Was this translation helpful? Give feedback.
Just wanted to post the solution here. The missing key was to pass the custom client to the Vue plugin init, in
main.ts
:Works great!