title: Error from controller not getting into axios catch block
body: <p>I am trying to catch the errors thrown by a rails controller. But The errors do not seem to reach the catch block, how should I go about it.</p>
  <pre><code>    axios
        .post(&quot;/api/dashboard/posts&quot;, {
          ...data,
        })
        .then((response) =&gt; {
          console.log(&quot;ERROR&quot;, response)
          if (response.status === 200) {
            console.log(&quot;CREATED!&quot;);
          } else {
            console.log(&quot;gets here, throw the error a&quot;)
            throw new Error(&quot;Error&quot;);
          }
        })
        .catch((error) =&gt; {
          console.log(&quot;ERRORS&quot;, error);
        });
  </code></pre>
  <pre><code>      def create
          post = Post.new(post_params)
          if post.save
            render json: {}, status: 200
          else
            render json: { error_message: post.errors }, status: 422
          end
        end
  
  </code></pre>
  <p>When the response is successful I get <code>console.log(&quot;CREATED!&quot;)</code> as I want it prompted on the console. But when <code>post</code> does not save, the error does not get into the catch block.</p>