Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. export const registerUser = (userData) => dispatch => {
  2.  
  3. Axios
  4. .post('/users/register', userData)
  5. .then( res => {
  6. const token = res.data.token;
  7. console.log(token);
  8. // pass the token in session
  9. sessionStorage.setItem("jwtToken", token);
  10. // set the auth token
  11. setAuthToken(token);
  12. // decode the auth token
  13. const decoded = jwt_decode(token);
  14. // pass the decoded token
  15. dispatch(setCurrentUser(decoded))
  16. this.props.history.push("/dashboard")
  17. }).catch( (err) => {
  18.  
  19. console.log(err.response)
  20. dispatch({
  21. type: GET_ERRORS,
  22. payload: err.response.data
  23. })
  24. })
  25. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement