@@ -677,7 +677,7 @@ const w = wretch().middlewares([retry(), dedupe()])
677
677
>
678
678
> ``` js
679
679
> // Replace the default condition with a custom one to avoid retrying on 4xx errors:
680
- > until : (response , error ) => response && (response .ok || (response .status >= 400 && response .status < 500 ))
680
+ > until : (response , error ) => !! response && (response .ok || (response .status >= 400 && response .status < 500 ))
681
681
> ` ` `
682
682
683
683
` ` ` js
@@ -690,20 +690,20 @@ wretch().middlewares([
690
690
delayTimer: 500 ,
691
691
delayRamp : (delay , nbOfAttempts ) => delay * nbOfAttempts,
692
692
maxAttempts: 10 ,
693
- until : (response , error ) => response && response .ok ,
694
- onRetry: null ,
693
+ until : (response , error ) => !! response && response .ok ,
694
+ onRetry: undefined ,
695
695
retryOnNetworkError: false ,
696
696
resolveWithLatestResponse: false
697
697
})
698
- ]). /* ... */
698
+ ])
699
699
700
700
// You can also return a Promise, which is useful if you want to inspect the body:
701
701
wretch ().middlewares ([
702
702
retry ({
703
703
until : response =>
704
- response .clone ().json ().then (body =>
704
+ response? .clone ().json ().then (body =>
705
705
body .field === ' something'
706
- )
706
+ ) || false
707
707
})
708
708
])
709
709
` ` `
@@ -723,7 +723,7 @@ wretch().middlewares([
723
723
key : (url , opts ) => opts .method + ' @' + url,
724
724
resolver : response => response .clone ()
725
725
})
726
- ]). /* ... */
726
+ ])
727
727
` ` `
728
728
729
729
### [Throttling Cache 🔗](https://elbywan.github.io/wretch/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware)
@@ -745,7 +745,7 @@ wretch().middlewares([
745
745
condition : response => response .ok ,
746
746
flagResponseOnCacheHit: ' __cached'
747
747
})
748
- ]). /* ... */
748
+ ])
749
749
` ` `
750
750
751
751
### [Delay 🔗](https://elbywan.github.io/wretch/api/types/middlewares_delay.DelayMiddleware)
@@ -758,7 +758,7 @@ import { delay } from 'wretch/middlewares'
758
758
759
759
wretch ().middlewares ([
760
760
delay (1000 )
761
- ]). /* ... */
761
+ ])
762
762
` ` `
763
763
764
764
## Writing a Middleware
0 commit comments