TanStackT
TanStack2y ago
7 replies
accused-moccasin

Query not retrying after axios 401 error

I'm using useQuery to call an axios function to make an API call. When I load the relevant page, I can see the query making an initial attempt which results in a 401 response which axios raises as an error. (This happens because the very first call to this function doesn't yet have access to my API JWT for authentication.) The strange thing is that, after the initial 401 failure, the query does not retry (which is annoying, because it would then have access to my JWT token). Can anyone shed some light on why this might be happening? To clarify, Axios seems to be returning a failed promise after the 401 error, so react-query should be receiving that failed promise.
Was this page helpful?