title: Post request with axios and redux-thunk in a redux-form
body: <p>I can't figure how to make a post request with axios and redux-thunk so the action is dispatched after the query.</p>
  
  <p>Here's my request module</p>
  <pre class="lang-js prettyprint-override"><code>export default {
      get: function (action, url) {
          return (dispatch) =&gt; {
              axios.get(`${ROOT_URL}${url}`)
                  .then(({ data }) =&gt; {
                      dispatch({
                          type: action,
                          payload: data
                      });
                  });
          };
      },
  
      post: function (action, url, props) {
          return (dispatch) =&gt; {
              axios.post(`${ROOT_URL}${url}`, props)
                  .then(({ data }) =&gt; {
                      return (dispatch) =&gt; {
                          dispatch({
                              type: action,
                              payload: data
                          });
                      };
                  });
          };
  
      }
  } 
  </code></pre>
  <p>The GET works. When I call the post function, it enters the function, but never run the returned function.</p>
  <p>I tried modifying the order of the functions. I ended up with a working post request, but the action was never dispatched.</p>
  <pre class="lang-js prettyprint-override"><code>post: function (action, url, props) {
          //POST works but action is not dispatched to reducer
          axios.post(`${ROOT_URL}${url}`, props)
              .then(({ data }) =&gt; {
                  return (dispatch) =&gt; {
                      dispatch({
                          type: action,
                          payload: data
                      });
                  };
              });
      }
  </code></pre>
  <p>Any idea how I can achieve a working post request that gets send to my api and then the response is dispatched to the reducer?</p>
  <p>Thank you!</p>
  <h1>UPDATE</h1>
  <p>After extensive testing and back and forth, I think the problem is in redux-form. As pointed by Michael, the dispatch should work. I tested my call in my component with the get method and it doesn't work. Here's my component</p>
  <pre class="lang-js prettyprint-override"><code>const form = reduxForm({
      form: 'LoginPage',
      validate
  });
  
  const renderField = ({ input, label, type, meta: { touched, error } }) =&gt; (
      &lt;div className=&quot;form-group&quot;&gt;
          &lt;label&gt;{label}&lt;/label&gt;
          &lt;div&gt;
              &lt;input {...input} placeholder={label} type={type} className=&quot;form-control&quot; /&gt;
              {touched &amp;&amp; ((error &amp;&amp; &lt;span&gt;{error}&lt;/span&gt;))}
          &lt;/div&gt;
      &lt;/div&gt;
  )
  
  class LoginPage extends Component {
      displayName: 'LoginPage';
  
      onSubmit(props) {
          login(props.email, props.password);
      }
  
      render() {
  
          const {handleSubmit} = this.props;
  
          return (
              &lt;div className='row'&gt;
                  &lt;div className='center-block'&gt;
                      &lt;form onSubmit={handleSubmit(this.onSubmit.bind(this))}&gt;
                          &lt;Field name=&quot;email&quot; type=&quot;email&quot; label='Courriel :' component={renderField} /&gt;
  
                          &lt;Field name=&quot;password&quot; type=&quot;password&quot; label='Mot de passe :' component={renderField} /&gt;
  
                          &lt;div className=&quot;form-group text-center&quot;&gt;
                              &lt;button type=&quot;submit&quot; className='btn btn-primary'&gt;Se connecter&lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/form &gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          );
      };
  };
  
  const validate = values =&gt; {
      const errors = {}
      if (!values.email) {
          errors.email = 'Required'
      } else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(values.email)) {
          errors.email = 'Invalid email address'
      }
      if (!values.password) {
          errors.password = 'Required'
      } 4
      return errors
  }
  
  export default reduxForm({
      form: 'LoginPage',
      validate
  })(LoginPage);
  </code></pre>
  <p>The post request is in the onSubmit method. The login method is called but the return value is never dispatched.</p>
  <p>Again, thank you for your time and help</p>