Advertisement
Guest User

loginReducer

a guest
Nov 14th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import loginService from '../services/login'
  2.  
  3. const loginReducer = (state = '', action) => {
  4.  
  5.   switch (action.type) {
  6.   case 'SET_LOGIN':
  7.     return action.data
  8.   default:
  9.     return state
  10.   }
  11. }
  12.  
  13. export const acLogin = ({ username, password }) => {
  14.   return async dispatch => {
  15.     const user = await loginService.login({ username, password })
  16.     dispatch({
  17.       type: 'SET_LOGIN',
  18.       data: user
  19.     })
  20.   }
  21. }
  22.  
  23. export default (loginReducer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement