How to not show Axios errors in console?
Is it possible to not show axios errors in console while using React Query?
I have simple code:
When user is not authenticated, server responses with 401.
When I try to get data using
It tries 4 times with console.log
GET * 401 (Unauthorized) and then finishing with AxiosError {message: 'Request failed with status code 401'
I expect to see more suitable error in console, but not axios one.6 Replies
like-goldOP•3y ago
Also is my code is good enought or it can be improved?
rival-black•3y ago
1) you only see those in dev mode, not production
2) we have removed logging failed queries in v5
3) in v4, you can use a custom logger to turn off error logging, but you'll have to remove the custom logger in v5 (because of point 2)
rival-black•3y ago
Custom Logger | TanStack Query Docs
If you want to change how information is logged by TanStack Query, you can set a custom logger when creating a QueryClient.
`tsx
like-goldOP•3y ago
Thanks for help! So I see initial error from query in dev mode just for information purposes right?
I thought I did smth wrong with catching exceptions.
Is it better to use v4 or v5 will not have any major changes and it is already safe to use for production purposes?
rival-black•3y ago
we're going to ship a release candidate soon; I don't expect any major api changes anymore
like-goldOP•3y ago
thanks!