File tree Expand file tree Collapse file tree 1 file changed +18
-22
lines changed
client/modules/IDE/actions Expand file tree Collapse file tree 1 file changed +18
-22
lines changed Original file line number Diff line number Diff line change @@ -11,20 +11,18 @@ function setAssets(assets, totalSize) {
11
11
}
12
12
13
13
export function getAssets ( ) {
14
- return ( dispatch ) => {
14
+ return async ( dispatch ) => {
15
15
dispatch ( startLoader ( ) ) ;
16
- apiClient
17
- . get ( '/S3/objects' )
18
- . then ( ( response ) => {
19
- dispatch ( setAssets ( response . data . assets , response . data . totalSize ) ) ;
20
- dispatch ( stopLoader ( ) ) ;
21
- } )
22
- . catch ( ( ) => {
23
- dispatch ( {
24
- type : ActionTypes . ERROR
25
- } ) ;
26
- dispatch ( stopLoader ( ) ) ;
16
+ try {
17
+ const response = await apiClient . get ( '/S3/objects' ) ;
18
+ dispatch ( setAssets ( response . data . assets , response . data . totalSize ) ) ;
19
+ dispatch ( stopLoader ( ) ) ;
20
+ } catch ( error ) {
21
+ dispatch ( {
22
+ type : ActionTypes . ERROR
27
23
} ) ;
24
+ dispatch ( stopLoader ( ) ) ;
25
+ }
28
26
} ;
29
27
}
30
28
@@ -36,16 +34,14 @@ export function deleteAsset(assetKey) {
36
34
}
37
35
38
36
export function deleteAssetRequest ( assetKey ) {
39
- return ( dispatch ) => {
40
- apiClient
41
- . delete ( `/S3/${ assetKey } ` )
42
- . then ( ( response ) => {
43
- dispatch ( deleteAsset ( assetKey ) ) ;
44
- } )
45
- . catch ( ( ) => {
46
- dispatch ( {
47
- type : ActionTypes . ERROR
48
- } ) ;
37
+ return async ( dispatch ) => {
38
+ try {
39
+ await apiClient . delete ( `/S3/${ assetKey } ` ) ;
40
+ dispatch ( deleteAsset ( assetKey ) ) ;
41
+ } catch ( error ) {
42
+ dispatch ( {
43
+ type : ActionTypes . ERROR
49
44
} ) ;
45
+ }
50
46
} ;
51
47
}
You can’t perform that action at this time.
0 commit comments