title: ResponseEntity and JavaScript - how to retrieve custom error message
body: <p>I wonder what is the best way to retrieve a message from server (Spring Boot) and display in frontend (Vue JS, ES6).</p>
  <p>Backend (its my only approach with success, to pass error message in header, but maybe there is a better solution?):</p>
  <pre><code>public ResponseEntity&lt;?&gt; getOneReport(@PathVariable Long incidentId) {
  
  ...
  
      HttpHeaders header = new HttpHeaders();
      header.setContentType(MediaType.TEXT_PLAIN);
      header.set(&quot;text&quot;, &quot;My custom error message&quot;);
      return ResponseEntity.notFound()
              .headers(header)
              .build();
  </code></pre>
  <p>Frontend:</p>
  <pre><code>axios.get(...)
  .then(...)
  .catch((error) =&gt; {
        console.log(error.headers.text);
  </code></pre>
  <p>I tried to pass my custom error message from service to client like this:</p>
  <pre><code>return new ResponseEntity&lt;Object&gt;(
                  &quot;My custom error message that I want to display in frontend&quot;, new HttpHeaders(), HttpStatus.FORBIDDEN);
  </code></pre>
  <p>but I don't know how to read that message from my client (ES6/Vue js):</p>
  <pre><code>.catch((error) =&gt; {
                          console.log(error.error);
  </code></pre>
  <p>or</p>
  <pre><code>.catch((error) =&gt; {
                          console.log(error.response.data); -&gt; I get Blob {size: 59, type: &quot;text/plain&quot;}
  </code></pre>