Skip to content

Commit 8f1618b

Browse files
fix crashing of app
1 parent c448094 commit 8f1618b

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

client/modules/IDE/actions/collections.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ export function getCollections(username) {
2727
dispatch(stopLoader());
2828
})
2929
.catch((error) => {
30-
const { response } = error;
3130
dispatch({
3231
type: ActionTypes.ERROR,
33-
error: response.data
32+
error: error?.response?.data
3433
});
3534
dispatch(stopLoader());
3635
});
@@ -59,11 +58,10 @@ export function createCollection(collection) {
5958
browserHistory.push(location);
6059
})
6160
.catch((error) => {
62-
const { response } = error;
63-
console.error('Error creating collection', response.data);
61+
// console.error('Error creating collection', response.data);
6462
dispatch({
6563
type: ActionTypes.ERROR,
66-
error: response.data
64+
error: error?.response?.data
6765
});
6866
dispatch(stopLoader());
6967
});
@@ -91,14 +89,11 @@ export function addToCollection(collectionId, projectId) {
9189
return response.data;
9290
})
9391
.catch((error) => {
94-
const { response } = error;
9592
dispatch({
9693
type: ActionTypes.ERROR,
97-
error: response.data
94+
error: error?.response?.data
9895
});
9996
dispatch(stopLoader());
100-
101-
return response.data;
10297
});
10398
};
10499
}
@@ -124,14 +119,11 @@ export function removeFromCollection(collectionId, projectId) {
124119
return response.data;
125120
})
126121
.catch((error) => {
127-
const { response } = error;
128122
dispatch({
129123
type: ActionTypes.ERROR,
130-
error: response.data
124+
error: error?.response?.data
131125
});
132126
dispatch(stopLoader());
133-
134-
return response.data;
135127
});
136128
};
137129
}
@@ -149,13 +141,10 @@ export function editCollection(collectionId, { name, description }) {
149141
return response.data;
150142
})
151143
.catch((error) => {
152-
const { response } = error;
153144
dispatch({
154145
type: ActionTypes.ERROR,
155-
error: response.data
146+
error: error?.response?.data
156147
});
157-
158-
return response.data;
159148
});
160149
};
161150
}
@@ -174,13 +163,10 @@ export function deleteCollection(collectionId) {
174163
return response.data;
175164
})
176165
.catch((error) => {
177-
const { response } = error;
178166
dispatch({
179167
type: ActionTypes.ERROR,
180-
error: response.data
168+
error: error?.response?.data
181169
});
182-
183-
return response.data;
184170
});
185171
};
186172
}

client/modules/IDE/actions/preferences.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ function updatePreferences(formParams, dispatch) {
77
.put('/preferences', formParams)
88
.then(() => {})
99
.catch((error) => {
10-
const { response } = error;
1110
dispatch({
1211
type: ActionTypes.ERROR,
13-
error: response.data
12+
error: error?.response?.data
1413
});
1514
});
1615
}

client/modules/IDE/actions/project.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ export function getProject(id, username) {
6161
dispatch(setUnsavedChanges(false));
6262
})
6363
.catch((error) => {
64-
const { response } = error;
6564
dispatch({
6665
type: ActionTypes.ERROR,
67-
error: response.data
66+
error: error?.response?.data
6867
});
6968
});
7069
};
@@ -338,10 +337,9 @@ export function cloneProject(project) {
338337
dispatch(setNewProject(response.data));
339338
})
340339
.catch((error) => {
341-
const { response } = error;
342340
dispatch({
343341
type: ActionTypes.PROJECT_SAVE_FAIL,
344-
error: response.data
342+
error: error?.response?.data
345343
});
346344
});
347345
}
@@ -376,10 +374,9 @@ export function changeProjectName(id, newName) {
376374
}
377375
})
378376
.catch((error) => {
379-
const { response } = error;
380377
dispatch({
381378
type: ActionTypes.PROJECT_SAVE_FAIL,
382-
error: response.data
379+
error: error?.response?.data
383380
});
384381
});
385382
};

client/modules/IDE/actions/projects.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ export function getProjects(username) {
2222
dispatch(stopLoader());
2323
})
2424
.catch((error) => {
25-
const { response } = error;
2625
dispatch({
2726
type: ActionTypes.ERROR,
28-
error: response.data
27+
error: error?.response?.data
2928
});
3029
dispatch(stopLoader());
3130
});

0 commit comments

Comments
 (0)