Retries a request multiple times in case of an error (or until a custom condition is true).
💡 By default, the request will be retried if the response status is not in the 2xx range.
// Replace the default condition with a custom one to avoid retrying on 4xx errors: until: (response, error) =>response && (response.ok || (response.status >= 400 && response.status < 500))
// You can also return a Promise, which is useful if you want to inspect the body: wretch().middlewares([ retry({ until:response=> response.clone().json().then(body=> body.field === 'something' ) }) ])
Retry middleware
Retries a request multiple times in case of an error (or until a custom condition is true).