@@ -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,9 @@ export function createCollection(collection) {
5958 browserHistory . push ( location ) ;
6059 } )
6160 . catch ( ( error ) => {
62- const { response } = error ;
63- console . error ( 'Error creating collection' , response . data ) ;
6461 dispatch ( {
6562 type : ActionTypes . ERROR ,
66- error : response . data
63+ error : error ?. response ? .data
6764 } ) ;
6865 dispatch ( stopLoader ( ) ) ;
6966 } ) ;
@@ -91,14 +88,11 @@ export function addToCollection(collectionId, projectId) {
9188 return response . data ;
9289 } )
9390 . catch ( ( error ) => {
94- const { response } = error ;
9591 dispatch ( {
9692 type : ActionTypes . ERROR ,
97- error : response . data
93+ error : error ?. response ? .data
9894 } ) ;
9995 dispatch ( stopLoader ( ) ) ;
100-
101- return response . data ;
10296 } ) ;
10397 } ;
10498}
@@ -124,14 +118,11 @@ export function removeFromCollection(collectionId, projectId) {
124118 return response . data ;
125119 } )
126120 . catch ( ( error ) => {
127- const { response } = error ;
128121 dispatch ( {
129122 type : ActionTypes . ERROR ,
130- error : response . data
123+ error : error ?. response ? .data
131124 } ) ;
132125 dispatch ( stopLoader ( ) ) ;
133-
134- return response . data ;
135126 } ) ;
136127 } ;
137128}
@@ -149,13 +140,10 @@ export function editCollection(collectionId, { name, description }) {
149140 return response . data ;
150141 } )
151142 . catch ( ( error ) => {
152- const { response } = error ;
153143 dispatch ( {
154144 type : ActionTypes . ERROR ,
155- error : response . data
145+ error : error ?. response ? .data
156146 } ) ;
157-
158- return response . data ;
159147 } ) ;
160148 } ;
161149}
@@ -174,13 +162,10 @@ export function deleteCollection(collectionId) {
174162 return response . data ;
175163 } )
176164 . catch ( ( error ) => {
177- const { response } = error ;
178165 dispatch ( {
179166 type : ActionTypes . ERROR ,
180- error : response . data
167+ error : error ?. response ? .data
181168 } ) ;
182-
183- return response . data ;
184169 } ) ;
185170 } ;
186171}
0 commit comments