Skip to content

Commit c55cf5f

Browse files
authored
Merge pull request #2436 from Vikram125609/vikram/fix-used-async-await-getAssets-deleteAssetRequest
migration of assets actions to async/await
2 parents 65d8798 + b7b325e commit c55cf5f

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

client/modules/IDE/actions/assets.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ function setAssets(assets, totalSize) {
1111
}
1212

1313
export 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

3836
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
4944
});
45+
}
5046
};
5147
}

0 commit comments

Comments
 (0)