@@ -26,7 +26,10 @@ export function signUpUser(previousPath, formValues) {
2626 dispatch ( justOpenedProject ( ) ) ;
2727 browserHistory . push ( previousPath ) ;
2828 } )
29- . catch ( response => dispatch ( authError ( response . data . error ) ) ) ;
29+ . catch ( ( error ) => {
30+ const { response } = error ;
31+ dispatch ( authError ( response . data . error ) ) ;
32+ } ) ;
3033 } ;
3134}
3235
@@ -82,7 +85,8 @@ export function getUser() {
8285 preferences : response . data . preferences
8386 } ) ;
8487 } )
85- . catch ( ( response ) => {
88+ . catch ( ( error ) => {
89+ const { response } = error ;
8690 const message = response . message || response . data . error ;
8791 dispatch ( authError ( message ) ) ;
8892 } ) ;
@@ -98,7 +102,8 @@ export function validateSession() {
98102 dispatch ( showErrorModal ( 'staleSession' ) ) ;
99103 }
100104 } )
101- . catch ( ( response ) => {
105+ . catch ( ( error ) => {
106+ const { response } = error ;
102107 if ( response . status === 404 ) {
103108 dispatch ( showErrorModal ( 'staleSession' ) ) ;
104109 }
@@ -114,7 +119,10 @@ export function logoutUser() {
114119 type : ActionTypes . UNAUTH_USER
115120 } ) ;
116121 } )
117- . catch ( response => dispatch ( authError ( response . data . error ) ) ) ;
122+ . catch ( ( error ) => {
123+ const { response } = error ;
124+ dispatch ( authError ( response . data . error ) ) ;
125+ } ) ;
118126 } ;
119127}
120128
@@ -127,10 +135,13 @@ export function initiateResetPassword(formValues) {
127135 . then ( ( ) => {
128136 // do nothing
129137 } )
130- . catch ( response => dispatch ( {
131- type : ActionTypes . ERROR ,
132- message : response . data
133- } ) ) ;
138+ . catch ( ( error ) => {
139+ const { response } = error ;
140+ dispatch ( {
141+ type : ActionTypes . ERROR ,
142+ message : response . data
143+ } ) ;
144+ } ) ;
134145 } ;
135146}
136147
@@ -143,10 +154,13 @@ export function initiateVerification() {
143154 . then ( ( ) => {
144155 // do nothing
145156 } )
146- . catch ( response => dispatch ( {
147- type : ActionTypes . ERROR ,
148- message : response . data
149- } ) ) ;
157+ . catch ( ( error ) => {
158+ const { response } = error ;
159+ dispatch ( {
160+ type : ActionTypes . ERROR ,
161+ message : response . data
162+ } ) ;
163+ } ) ;
150164 } ;
151165}
152166
@@ -161,10 +175,13 @@ export function verifyEmailConfirmation(token) {
161175 type : ActionTypes . EMAIL_VERIFICATION_VERIFIED ,
162176 message : response . data ,
163177 } ) )
164- . catch ( response => dispatch ( {
165- type : ActionTypes . EMAIL_VERIFICATION_INVALID ,
166- message : response . data
167- } ) ) ;
178+ . catch ( ( error ) => {
179+ const { response } = error ;
180+ dispatch ( {
181+ type : ActionTypes . EMAIL_VERIFICATION_INVALID ,
182+ message : response . data
183+ } ) ;
184+ } ) ;
168185 } ;
169186}
170187
@@ -216,7 +233,10 @@ export function updateSettings(formValues) {
216233 dispatch ( showToast ( 5500 ) ) ;
217234 dispatch ( setToastText ( 'Settings saved.' ) ) ;
218235 } )
219- . catch ( response => Promise . reject ( new Error ( response . data . error ) ) ) ;
236+ . catch ( ( error ) => {
237+ const { response } = error ;
238+ Promise . reject ( new Error ( response . data . error ) ) ;
239+ } ) ;
220240}
221241
222242export function createApiKeySuccess ( user ) {
@@ -232,7 +252,10 @@ export function createApiKey(label) {
232252 . then ( ( response ) => {
233253 dispatch ( createApiKeySuccess ( response . data ) ) ;
234254 } )
235- . catch ( response => Promise . reject ( new Error ( response . data . error ) ) ) ;
255+ . catch ( ( error ) => {
256+ const { response } = error ;
257+ Promise . reject ( new Error ( response . data . error ) ) ;
258+ } ) ;
236259}
237260
238261export function removeApiKey ( keyId ) {
@@ -244,5 +267,8 @@ export function removeApiKey(keyId) {
244267 user : response . data
245268 } ) ;
246269 } )
247- . catch ( response => Promise . reject ( new Error ( response . data . error ) ) ) ;
270+ . catch ( ( error ) => {
271+ const { response } = error ;
272+ Promise . reject ( new Error ( response . data . error ) ) ;
273+ } ) ;
248274}
0 commit comments