diff --git a/package.json b/package.json index 49b3768b..ffd73ef1 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "react-inlinesvg": "^0.4.2", "react-redux": "^4.4.5", "redux": "^3.5.2", - "redux-form": "^5.2.5" + "redux-form": "^5.2.5", + "redux-thunk": "^2.1.0" } } diff --git a/shared/redux/actions/user.js b/shared/redux/actions/user.js index 5d8a48cb..3689a515 100644 --- a/shared/redux/actions/user.js +++ b/shared/redux/actions/user.js @@ -6,15 +6,21 @@ import axios from 'axios' const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000' : '/'; export function signUpUser(formValues) { - const request = axios.post(`${ROOT_URL}/signup`, formValues); - return function(dispatch) { axios.post(`${ROOT_URL}/signup`, formValues) .then(response => { - dispatch({ type: AUTH_USER }); + dispatch({ type: ActionTypes.AUTH_USER }); localStorage.setItem('token', response.data.token); browserHistory.push('/'); }) .catch(response => dispatch(authError(response.data.error))); } +} + + +export function authError(error) { + return { + type: ActionTypes.AUTH_ERROR, + payload: error + }; } \ No newline at end of file diff --git a/shared/redux/store/configureStore.js b/shared/redux/store/configureStore.js index b6aad8d9..a380e383 100644 --- a/shared/redux/store/configureStore.js +++ b/shared/redux/store/configureStore.js @@ -1,11 +1,12 @@ -import { createStore, applyMiddleware } from 'redux' +import { createStore, applyMiddleware, compose } from 'redux' +import thunk from 'redux-thunk' import rootReducer from '../reducers' export default function configureStore(initialState) { const store = createStore( rootReducer, - initialState - // applyMiddleware(thunk) + initialState, + applyMiddleware(thunk) ) if (module.hot) {