Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const registerUser = (userData) => dispatch => {
- Axios
- .post('/users/register', userData)
- .then( res => {
- const token = res.data.token;
- console.log(token);
- // pass the token in session
- sessionStorage.setItem("jwtToken", token);
- // set the auth token
- setAuthToken(token);
- // decode the auth token
- const decoded = jwt_decode(token);
- // pass the decoded token
- dispatch(setCurrentUser(decoded))
- this.props.history.push("/dashboard")
- }).catch( (err) => {
- console.log(err.response)
- dispatch({
- type: GET_ERRORS,
- payload: err.response.data
- })
- })
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement