Created
September 24, 2015 04:22
-
-
Save lancetw/7bf3dc2bccb567462a4b to your computer and use it in GitHub Desktop.
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
export function login (form) { | |
return async dispatch => { | |
dispatch({ type: AUTH_USER_STARTED }) | |
try { | |
const res = await auth(form) | |
if (res && res.token) { | |
setToken(res.token) | |
return dispatch({ | |
type: AUTH_USER_COMPLETED, | |
token: res.token | |
}) | |
} else throw new Error('no token') | |
} catch (err) { | |
return dispatch({ | |
type: AUTH_USER_FAILED, | |
errors: err.message | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment