user.js 559 Bytes
import axios from 'axios';

const REGISTER = 'user/REGISTER';

const InitialState = {
  name: 'test',
  id: 'test123',
  password: 'test1111~',
  gender: '1',
};

export function register(data) {
  const req = axios.post('http://localhost:4000/register', data)
    .then(res => res.data);

    return {
      type: REGISTER,
      payload: req,
    }
};

export default function (state = InitialState, action) {
  switch (action.type) {
    case REGISTER:
      return {...state, register: action.payload};
      break;
    default:
      return state;
  }
};