Last active
July 23, 2016 19:16
-
-
Save MrRoyce/9228884d8910d990d739f1f0dae03842 to your computer and use it in GitHub Desktop.
React/Redux code to login a user with axios - Issue with zombie.js testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Login the user | |
export const getUserLogin = (email, password) => { | |
let | |
url = `${GT_API_URL}/login` | |
; | |
console.log('getUserLogin'); // This text appears on the log | |
return function (dispatch) { | |
dispatch(userLoginRequest()); | |
return axios({ | |
url : url, | |
timeout : 20000, | |
method : 'post', | |
responseType : 'json', | |
data : { | |
email : email, | |
password : password | |
} | |
}) | |
.then( | |
response => { | |
console.log('success for user login response'); // This log does not appear | |
dispatch(userLoginSuccess(response)); // Store it in the state | |
}, | |
error => { | |
console.log('fail to login user'); // Neither does this one | |
dispatch(userLoginFailure()); | |
// Track the error | |
piwik.trackError( { message: error, filename: 'userAction', lineno: 229 }, 'User Login Error'); | |
} | |
) | |
; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment