Advertisement
Guest User

Untitled

a guest
Jan 12th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export const regStart = phoneNumber => {
  2.   return dispatch => {
  3.     dispatch({ type: REG_START });
  4.  
  5.     generatekeys()
  6.       .then(pubKey => {
  7.         const body = {
  8.           Phone: phoneNumber,
  9.           PublicKey: pubKey
  10.         };
  11.         return request(`${Constants.baseUrl}Register/SendSMS`, body);
  12.       })
  13.       .then(result => {
  14.         LOG('fetch: ' + JSON.stringify(result));
  15.         if (result.status === 200) {
  16.           console.log('fetch: success, name = ' + result.name);
  17.           dispatch({
  18.             type: REG_SUCCESS,
  19.             payload: {
  20.               result: JSON.parse(result._bodyInit)
  21.             }
  22.           });
  23.         } else {
  24.           dispatch({
  25.             type: REG_ERROR,
  26.             payload: `Failed to login with ${result.status}`
  27.           });
  28.         }
  29.       })
  30.       .catch(error => {
  31.         dispatch({
  32.           type: REG_ERROR,
  33.           payload: `Failed to login with ${error}`
  34.         });
  35.       })
  36.       .done();
  37.   };
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement