softonic / axios-retry

Axios plugin that intercepts failed requests and retries them whenever possible
Other
1.9k stars 167 forks source link

retryCondition calling a healthcheck api #194

Closed dstone1983 closed 2 years ago

dstone1983 commented 2 years ago

Hello All,

I am implementing retry logic to my system. I am attempting to only retry if the health check api comes back successful. It seems to be retrying no matter what.

doing a:

retryCondition:() => false

works

retryCondition: async () => { try { await axios.get(healthcheckurl) return true } catch(error) { return false } }

Is there a way to achievce this? I don't want it to retry if the healthcheck fails.

I appreciate the assistance

balmacefa commented 2 years ago

retryCondition is called if Axios return an Error

balmacefa commented 2 years ago

try this https://github.com/JustinBeckwith/retry-axios