Error handling
Hi guys!
I want to throw for second call when http response code is 500
const {data, isLoading, refetch, fetchNextPage} = useGetDeckSuspenseInfiniteQuery()
Steps to reproducate:
1. Load list: http 200
2. Change backend code to get http 500
3. Refrech list (called refetch, http code is 500)
It throws when first list load is http 500
But it not throws error because there is a previous data.
How can I throw it? What missing?
Thank you !




2 Replies
flat-fuchsiaOP•2y ago
also there is an axios interceptor to handle http 401 later

flat-fuchsiaOP•2y ago
Ah found the ultimate solution: https://tkdodo.eu/blog/react-query-error-handling#putting-it-all-together
React Query Error Handling
After covering the sunshine cases of data fetching, it's time to look at situations where things don't go as planned and "Something went wrong..."