Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'babel-polyfill'
- import fetch from 'isomorphic-fetch'
- import { browserHistory } from 'react-router'
- let actions = {
- addMessage(text) {
- return {
- type: 'ADD_MESSAGE',
- text: text,
- }
- },
- registerUser(data) {
- return () => {
- fetch('/signup', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- username: data.username,
- password: data.password,
- email: data.email,
- name: data.name
- })
- })
- .then((response) => response.text())
- .then((responseText) => {
- browserHistory.push('/');
- })
- .catch((error) => {
- console.warn(error);
- });
- }
- }
- }
- export default actions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement