title: Not receiving error response from API in Angular
body: <p>I'm calling an API in Angular and trying to get the response body, but it just displays <code>error message is [object Object]</code></p>
  <p>I've tried just doing <code>console.log(error)</code>, <code>error.text()</code> ,<code>JSON.parse(error._body).errors</code> ,<code>error.error</code> ,<code>error.message</code> and <code>error.json()</code>but none worked.</p>
  <p>This is my code, would really appreciate some help:</p>
  <pre><code>  doImport = (dataObj) =&gt; {
      for(let i = 0; i&lt;this.uploadedFilesCount; i++) {
        const filename = this.uploadedFileNames[i];
        this.disableDeployCTA = true;
        const params:string = filename + &quot;/&quot; + this.testStartTime + &quot;/&quot; + this.userNtId + &quot;/&quot; + this.userTeamID + &quot;/&quot; + this.userTeam; 
        var res = '';
        this.httpService.importUML(params).subscribe((response: any) =&gt; {        
          this.toastmessage.success('Successfully created test #'+i); 
          this.toastmessage.clear();
        },                              
        (error) =&gt; {
          console.log(&quot;error message is &quot;+error.message);
          if(error.status == 409) {
            if(res.indexOf(&quot;static data&quot;)!=-1) {
              this.toastmessage.error(filename + &quot;: That static data exists already!&quot;);
            }
            else {
              this.toastmessage.error(filename + &quot;: That test case exists already! Please change test case name.&quot;);
            }
          }
          else if(error.status == 400) {
            this.toastmessage.error(filename + &quot;: Incorrectly formatted UML. Please fix and try again.&quot;);
          }
        });
      }
      this.resetAxiForm();
      this.disableImport = true; 
    } 
  </code></pre>
  <p>And the error response I want to get:</p>
  <p><a href="https://i.stack.imgur.com/Rxxe4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rxxe4.png" alt="enter image description here" /></a></p>
  <p>When I do console.log(error):
  <a href="https://i.stack.imgur.com/DbpjP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DbpjP.png" alt="enter image description here" /></a></p>