ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.58k stars 1.33k forks source link

Retry only on when certain response codes #1635

Open narender56 opened 3 years ago

narender56 commented 3 years ago

I need to retry request on certain response codes, like 401, 406, Do superagent support this?

Example:

request
   .get('https://example.com/search')
   .retryWhen([401, 406]) <-- like this
   .then(finished);
   .catch(failed);

Any help would appreciated. Thank you!