function sendData(jsonData) {
  request
  .post('/v1/register/')
  .send(jsonData)
  .end((error, res) => {
    if (error) {
      let errorText = 'An unexpected error occurred';
      if (error.response.body.errors[0].message ===
       'User already exists') {
        errorText = 'User already exists';
      }

      document.getElementById('errorInfo').innerHTML = errorText;
    } else {
      window.location.href = '/';
    }
  });
}
/**
 * Send request to register api and get result. Redirect to index page if
 * registration succeeded, else display error.
 * @param  {Object} jsonData json object with user credentials
 */
Send request to register api and get result. Redirect to index page if
registration succeeded, else display error.
@param  {Object} jsonData json object with user credentials
Send request to register api and get result . Redirect to index page if registration succeeded else display error . @param { Object } jsonData json object with user credentials
function sendData(jsonData) {
  request
  .post('/v1/register/')
  .send(jsonData)
  .end((error, res) => {
    if (error) {
      let errorText = 'An unexpected error occurred';
      if (error.response.body.errors[0].message ===
       'User already exists') {
        errorText = 'User already exists';
      }
      document.getElementById('errorInfo').innerHTML = errorText;
    } else {
      window.location.href = '/';
    }
  });
}
function sendData ( jsonData ) { request . post ( '/v1/register/' ) . send ( jsonData ) . end ( ( error , res ) => { if ( error ) { let errorText = 'An unexpected error occurred' ; if ( error . response . body . errors [ 0 ] . message === 'User already exists' ) { errorText = 'User already exists' ; } document . getElementById ( 'errorInfo' ) . innerHTML = errorText ; } else { window . location . href = '/' ; } } ) ; }
Send request to register api and get result.
Send request to register api and get result .