I am using onError callback to show toast messsage globally. And I also want to clear all cache If user gets 401. But in error callback error and query parameters don't have any method to achieve this. How can I do it?
const queryClient = useMemo(
() =>
new QueryClient({
queryCache: new QueryCache({
onError: (error, query) => {
handleToastErrorMessage(error);
if (error.response.status === 401) {
// I want to remove all queries from cache here
// removeQueries();
}
},
}), []);