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) {
1111}
1212
1313export function getAssets ( ) {
14- return ( dispatch ) => {
14+ return async ( dispatch ) => {
1515 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
2723 } ) ;
24+ dispatch ( stopLoader ( ) ) ;
25+ }
2826 } ;
2927}
3028
@@ -36,16 +34,14 @@ export function deleteAsset(assetKey) {
3634}
3735
3836export 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
4944 } ) ;
45+ }
5046 } ;
5147}
You can’t perform that action at this time.
0 commit comments