@@ -106,12 +106,14 @@ export const taskWithFetchRetries = task({
106
106
// if the Response is a 429 (too many requests), it will retry using the data from the response. A lot of good APIs send these headers.
107
107
const headersResponse = await retry .fetch (" http://my.host/test-headers" , {
108
108
retry: {
109
- " 429" : {
110
- strategy: " headers" ,
111
- limitHeader: " x-ratelimit-limit" ,
112
- remainingHeader: " x-ratelimit-remaining" ,
113
- resetHeader: " x-ratelimit-reset" ,
114
- resetFormat: " unix_timestamp_in_ms" ,
109
+ byStatus: {
110
+ " 429" : {
111
+ strategy: " headers" ,
112
+ limitHeader: " x-ratelimit-limit" ,
113
+ remainingHeader: " x-ratelimit-remaining" ,
114
+ resetHeader: " x-ratelimit-reset" ,
115
+ resetFormat: " unix_timestamp_in_ms" ,
116
+ },
115
117
},
116
118
},
117
119
});
@@ -121,13 +123,15 @@ export const taskWithFetchRetries = task({
121
123
// if the Response is a 500-599 (issue with the server you're calling), it will retry up to 10 times with exponential backoff
122
124
const backoffResponse = await retry .fetch (" http://my.host/test-backoff" , {
123
125
retry: {
124
- " 500-599" : {
125
- strategy: " backoff" ,
126
- maxAttempts: 10 ,
127
- factor: 2 ,
128
- minTimeoutInMs: 1_000 ,
129
- maxTimeoutInMs: 30_000 ,
130
- randomize: false ,
126
+ byStatus: {
127
+ " 500-599" : {
128
+ strategy: " backoff" ,
129
+ maxAttempts: 10 ,
130
+ factor: 2 ,
131
+ minTimeoutInMs: 1_000 ,
132
+ maxTimeoutInMs: 30_000 ,
133
+ randomize: false ,
134
+ },
131
135
},
132
136
},
133
137
});
@@ -136,9 +140,9 @@ export const taskWithFetchRetries = task({
136
140
137
141
// You can additionally specify a timeout. In this case if the response takes longer than 1 second, it will retry up to 5 times with exponential backoff
138
142
const timeoutResponse = await retry .fetch (" https://httpbin.org/delay/2" , {
139
- timeout: {
140
- durationInMs: 1000 ,
141
- retry : {
143
+ timeoutInMs: 1000 ,
144
+ retry: {
145
+ timeout : {
142
146
maxAttempts: 5 ,
143
147
factor: 1.8 ,
144
148
minTimeoutInMs: 500 ,
0 commit comments