daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export function signInUser(email, password) {
  2.     return function (dispatch) {
  3.         return new Promise((resolve, reject) => {
  4.             API.users.login({
  5.                 'username': email,
  6.                 'password': password
  7.             })
  8.             .then(response => {
  9.                 setToken(response.data.token);
  10.                 dispatch({
  11.                     type: 'SIGN_IN_USER',
  12.                     payload: {
  13.                         'name': '',
  14.                         'token': response.data.token
  15.                     }
  16.                 });
  17.                 resolve(response);
  18.             })
  19.             .catch(error => {
  20.                 reject(error);
  21.             });
  22.         });
  23.     };
  24. }
  25.  
  26. export function registerUser(email, password) {
  27.     return function dispatch() {
  28.         return new Promise((resolve, reject) => {
  29.             API.users.register({
  30.                 'email': email,
  31.                 'password': password
  32.             })
  33.             .then(response => {
  34.                 resolve(response);
  35.             })
  36.             .catch(error => {
  37.                 reject(error);
  38.             });
  39.         });
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top