Advertisement
Guest User

Untitled

a guest
Apr 24th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import 'babel-polyfill'
  2. import fetch from 'isomorphic-fetch'
  3. import { browserHistory } from 'react-router'
  4.  
  5.  
  6. let actions = {
  7.  
  8. addMessage(text) {
  9. return {
  10. type: 'ADD_MESSAGE',
  11. text: text,
  12. }
  13. },
  14.  
  15. registerUser(data) {
  16. return () => {
  17. fetch('/signup', {
  18. method: 'POST',
  19. headers: {
  20. 'Accept': 'application/json',
  21. 'Content-Type': 'application/json',
  22. },
  23. body: JSON.stringify({
  24. username: data.username,
  25. password: data.password,
  26. email: data.email,
  27. name: data.name
  28. })
  29. })
  30. .then((response) => response.text())
  31. .then((responseText) => {
  32. browserHistory.push('/');
  33. })
  34. .catch((error) => {
  35. console.warn(error);
  36. });
  37. }
  38. }
  39. }
  40. export default actions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement