Retry calls using the Retry-After header. #6565
-
Hi! I'm testing React Query to enhance the performance of my app. I would like to utilize the Retry-After header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) to obtain its value and use this time delay for retrying calls. Is there a way to configure React Query to incorporate this header for retry functionality? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
React Query knows nothing about http headers because it's not tied to http at all. It's a promise based state manager, which means you can do anything as long as your In your case, here's what I would do:
|
Beta Was this translation helpful? Give feedback.
React Query knows nothing about http headers because it's not tied to http at all. It's a promise based state manager, which means you can do anything as long as your
queryFn
returns a resolved or rejected promise.In your case, here's what I would do:
querFn
, make your api call with your favourite tool.queryFn
Retry-After
headerretryAfter
you can look atretryDelay
function to look at the custom error and return a number in millis for how long to wait, something like: