Simple question regarding redirecting on error
I have a simple question. Take the following code:
This works, but it tries three times so it actually takes a few seconds to redirect to
/signup
if the user is logged out (401). Can I detect a 401 the first time and redirect right away?2 Replies
sensitive-blue•9mo ago
https://tanstack.com/query/latest/docs/framework/react/guides/important-defaults
https://tanstack.com/query/latest/docs/framework/react/guides/query-retries
Probably still have the default set to 3. You can change it globally or for just that query
Important Defaults | TanStack Query React Docs
Out of the box, TanStack Query is configured with aggressive but sane defaults. Sometimes these defaults can catch new users off guard or make learning/debugging difficult if they are unknown by the u...
Query Retries | TanStack Query React Docs
When a useQuery query fails (the query function throws an error), TanStack Query will automatically retry the query if that query's request has not reached the max number of consecutive retries (defau...
genetic-orangeOP•9mo ago
thanks!