1
0
Fork 0

Start working on reducer for auth

This commit is contained in:
Amarpreet Minhas 2019-09-14 22:12:43 -04:00
parent aa6f98f91f
commit 4b97b943e8
3 changed files with 18 additions and 2 deletions

View file

@ -27,5 +27,5 @@ export const userLogin = (username, password) => async (dispatch) => {
}).catch(function (error) {
console.log(error);
});
console.log(response)
dispatch({ type: 'USER_LOGIN', payload: response })
};

View file

@ -0,0 +1,14 @@
const initialState = {
user_logged_in: false,
username: '',
jwt: ''
};
export default (state = initialState, action) => {
switch (action.type) {
case 'USER_LOGIN':
return {jwt: action.payload}
default:
return state;
}
};

View file

@ -1,8 +1,10 @@
import { combineReducers } from 'redux';
import postsReducer from './postsReducer';
import userReducer from './userReducer';
import authReducer from './authReducer';
export default combineReducers({
posts: postsReducer,
user: userReducer
user: userReducer,
auth: authReducer
});