title: ReactJS -Throw Submission Error with axios response
body: <p>I am having understanding problem to make my code work properly. Basically I want to validate a data from server, which on validation doesn't throw error but give proper response where I need to handle the response and throw Submission Error to show validation error with redux-form.</p>
  
  <p>Following is my code..</p>
  
  <pre><code>onFormSubmit = (values) =&gt;{
      this.setState({loading:true});
      this.props.validateEmailFromServer(this.props.session,values,(response)=&gt;{
        if(response.success === 2){
          throw new SubmissionError({email:'Email already Taken', _error:'Failed'});
        }
      });
  }
  </code></pre>
  
  <p>Action is defined as follows</p>
  
  <pre><code>export function validateEmailFromServer(session,values,callback){
  
    var url='API_URL';
    var response = axios.get(url, null, 
                             getHeaders(session));
    return (dispatch) =&gt; {
      response.then(({data}) =&gt; {
        if(data.resource.length&gt;0){
          callback({success: 2,message:'Email id is not available!'});
        }else{
          callback({success: 1,message:'Email is available!'});
        }
      }).catch((error) =&gt; {
        callback({success: 0, message: error});
      });
    }
  }
  </code></pre>
  
  <p>The problem I am facing is when I am throwing the <strong>Submission Error</strong> when callback is called on <strong>onFormSubmit</strong> function it is calling the error block of axios automatically, I am not able to get out of it..</p>
  
  <p>I need help to solve this problem.</p>
  
  <p>Thanks.</p>