File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import useAsync from '../utils/useAsync';
6
6
7
7
axios . defaults . timeout = 3000 ;
8
8
9
- export type Version = 'simple' | 'timeout' | 'exception' | 'parallel' | 'circuitBreaker' | 'retry' ;
9
+ export type Version = 'simple' | 'timeout' | 'exception' | 'parallel' | 'circuitBreaker' | 'retry' | 'fallback' ;
10
10
11
11
export function useProducts ( version : Version ) {
12
12
const [ timestamp , setTimestamp ] = React . useState ( new Date ( ) ) ;
@@ -20,6 +20,8 @@ export function useProducts(version: Version) {
20
20
return ProductService . parallel . fetch ( ) ;
21
21
case 'circuitBreaker' :
22
22
return ProductService . circuitBreaker . fetch ( ) ;
23
+ case 'fallback' :
24
+ return ProductService . fallback . fetch ( ) ;
23
25
case 'retry' :
24
26
return ProductService . retry . fetch ( ) ;
25
27
default :
@@ -65,6 +67,11 @@ export const ProductService = {
65
67
return ( await axios . get ( '/products/circuitbreaker' ) ) . data ;
66
68
} ,
67
69
} ,
70
+ fallback : {
71
+ async fetch ( ) : Promise < Products > {
72
+ return ( await axios . get ( '/products/fallback' ) ) . data ;
73
+ } ,
74
+ } ,
68
75
retry : {
69
76
async fetch ( ) : Promise < Products > {
70
77
return ( await axios . get ( '/products/retry' ) ) . data ;
You can’t perform that action at this time.
0 commit comments