Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. _handleOnSubmit(values) {
  2.  
  3.         var self = this;
  4.  
  5.         let pt_data = JSON.stringify({
  6.             firstName: values.name,
  7.             email: values.email,
  8.             password: values.password
  9.         });
  10.  
  11.         axios({
  12.             method: 'post',
  13.             url: apiUrl.registerPersonalTrainer,
  14.             data: pt_data,
  15.             headers: {
  16.                 'Content-type': 'application/json'
  17.             }
  18.         })
  19.             .then(function (response) {
  20.                 self.setState({
  21.                     responseMessage: "Almost there... We just sent you a link for your email. Click that link to verify your account.",
  22.                     responseCode: response.status
  23.                 });
  24.             })
  25.             .catch(function (error) {
  26.                 if(error.response) {
  27.                     // The request was made and the server responded with a status code
  28.                     if(error.response.status === 302) {
  29.                         self.setState({
  30.                             responseMessage: "Email already in use! Try to sign up with different email account.",
  31.                             responseCode: error.response.status
  32.                         });
  33.                     }
  34.                 } else if (error.request) {
  35.                     // The request was made but no response was received
  36.                     console.log(error.request);
  37.                     self.setState({
  38.                         responseMessage: "We are sorry! Something went wrong. Try again later, please.",
  39.                         responseCode: error.request.status
  40.                     });
  41.                 } else {
  42.                     // Something happened in setting up the request that triggered an Error
  43.                     console.log('Error:', error.message);
  44.                 }
  45.             });
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement