Last active
September 11, 2019 16:10
-
-
Save kavinduchamiran/910d67b9f82e3795794851a543e5d275 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
import axios from "axios"; | |
import setAuthToken from "../utils/setAuthToken"; | |
import jwt_decode from "jwt-decode"; | |
import { | |
GET_ERRORS, | |
SET_CURRENT_USER, | |
USER_LOADING | |
} from "./types"; | |
// Register User | |
export const registerUser = (userData, history) => dispatch => { | |
axios | |
.post("/api/users/register", userData) | |
.then(res => history.push("/login")) // re-direct to login on successful register | |
.catch(err => | |
dispatch({ | |
type: GET_ERRORS, | |
payload: err.response.data | |
}) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment