Skip to content

Instantly share code, notes, and snippets.

@kavinduchamiran
Last active September 11, 2019 16:10
Show Gist options
  • Save kavinduchamiran/910d67b9f82e3795794851a543e5d275 to your computer and use it in GitHub Desktop.
Save kavinduchamiran/910d67b9f82e3795794851a543e5d275 to your computer and use it in GitHub Desktop.
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