Guest User

Untitled

a guest
Jun 1st, 2017
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import * as types from '../constants/UserTypes'
  2. import {ajaxRequest} from './BaseAction'
  3.  
  4. const createUser = userData => {
  5. let data = {
  6. firstname: userData.firstName,
  7. lastname: userData.lastName,
  8. email: userData.email,
  9. password: userData.password,
  10. login: userData.login,
  11. birthday: userData.birthday,
  12. phone: userData.phone
  13. }
  14.  
  15. return dispatch => {
  16. console.log(data);
  17. return ajaxRequest('POST', '/register', data, false, {
  18. 201: () => {
  19. dispatch({
  20. type: types.CREATE_USER
  21. })
  22. },
  23. 422: data => {
  24. dispatch({
  25. type: types.CREATE_USER_FAIL,
  26. error: JSON.parse(data.data.responseText)
  27. })
  28. }
  29. })
  30. }
  31. }
  32.  
  33. export {createUser}
Add Comment
Please, Sign In to add comment