Closed Siemko closed 5 years ago
Hi @Siemko, sorry that I couldn't reply earlier.
Is there a way to make retry middleware work only on specified error (503 with specified json result)?
I just pushed an update to the RetryMiddleware
that allows returning a Promise in the until
option.
You can use it like this to retry until you get a specified error & body response that satisfy your condition:
wretch('https://jsonplaceholder.typicode.com/todos/1').middlewares([
retry({
until: response => (
response.status === 503 &&
response.json().then(body => (
// body checks here
))
)
})
]).get().json(body =>
// ....
)
Is there a way to make retry middleware work only on specified error (503 with specified json result)?