Extend retry statusCode in order to work for 404. #1813
Replies: 3 comments 3 replies
-
retry: { statusCodes: [...got.defaults.options.retry.statusCodes, 404] }, |
Beta Was this translation helpful? Give feedback.
-
Duplicate of #1780 |
Beta Was this translation helpful? Give feedback.
-
@szmarczak This is not necessarily a duplicate, as the usage is a bit different. The reason why @sindresorhus answer could not be accepted and the reason why @y0x originally had an issue was due to a typo. They had singular usage of |
Beta Was this translation helpful? Give feedback.
-
I’m making HTTP requests to an API where I can expect an HTTP code 404 under certain conditions. I’d like to use Got's internal retry functionality for rerunning the request until the 404 error is gone (which will happen; I just don't know if it takes 1 minute or 30 minutes).
From the documentation I know that HTTP code 404 is not a supported statusCode for the built-in retry functionality and therefore I cannot perform any action within the beforeRetry hook of Got.
I’m extending a Got instance to allow some presets for the API I’m calling. For now I have not found a clean way to extend the existing retry statusCodes with 404.
I´m aware that I could just catch the 404 and then do the retry manually, just asking for a way of doing it internal.
Thanks for the awesome lib, love it!
Checklist
Beta Was this translation helpful? Give feedback.
All reactions