title: Get API returning HttpErrorrResponse in angular code with error code 302 and response json wrpaped in error
body: <p>I have written a simple GET API which is returning a list of Claim.
  The url of the API is 
  <code>http://localhost:8898/claim/v1/claimByClaimNum/' + claimNumber</code></p>
  
  <p>Now when I am invoking this through my angular code using <code>HttpClient</code>, 
  I am getting <code>HttpErrorResponse</code>.</p>
  
  <p>I am calling Rest API by the below code in my <code>Service.ts</code></p>
  
  <pre class="lang-js prettyprint-override"><code>import { Injectable } from '@angular/core';
  import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
  import { ClaimResultItem } from '../claim-result/claim-result-item.model';
  import { map } from 'rxjs/operators';
  import { Observable } from 'rxjs';
  
  @Injectable()
  export class ClaimHttpService {
  
    constructor(private http: HttpClient) { }
  
    getClaimsByClaimNumber(claimNumber: string) {
  
      this.http.get&lt;ClaimResultItem&gt;
        ('http://localhost:8898/claim/v1/claimByClaimNum/' + claimNumber)
        .subscribe((response =&gt; {
          console.log(response.subjectId);
        }
        ));
    }
  }
  </code></pre>
  
  <p>When I am calling above method, I am getting below error-</p>
  
  <pre><code>HttpErrorResponse {headers: HttpHeaders, status: 302, statusText: "OK", 
  url: "http://localhost:8898/claim/v1/claimByClaimNum/1234", ok: false, …}
  error: {claimNumber: "1234", claimStatus: "Paid", claimAmount: "125.00", 
  claimStartDate: "2019-01-01", claimEndDate: "2019-05-01", …}
  headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, 
  lazyInit: ƒ}
   message: "Http failure response for 
  http://localhost:8898/claim/v1/claimByClaimNum/1234: 302 OK"
  name: "HttpErrorResponse"
  ok: false
  status: 302
  statusText: "OK"
   url: "http://localhost:8898/claim/v1/claimByClaimNum/1234"
   __proto__: HttpResponseBase
   constructor: ƒ HttpErrorResponse(init)
  __proto__:
   constructor: ƒ HttpResponseBase(init, defaultStatus, defaultStatusText)
   __proto__: Object
  </code></pre>
  
  <p>It seems that HttpClient is getting the response from the API but still wrapping it in error and returning it in 302 Http code.</p>
  
  <pre><code> error: {claimNumber: "1234", claimStatus: "Paid", claimAmount: "125.00", 
   claimStartDate: "2019-01-01", claimEndDate: "2019-05-01", …}
  </code></pre>
  
  <p>How to remove this error , any pointer will be helpful.</p>
  
  <p>My Rest API is working fine and giving me result when I am invoking it independently through Postman.Also Rest service is Cross origin resource supported.</p>
  
  <p>I am calling the method from component at <code>onSubmit()</code> at the click of the button </p>
  
  <pre class="lang-js prettyprint-override"><code>onSubmit() {
    console.log(this.form.value.claimNumber);
    this.claimHttpService.getClaimsByClaimNumber(this.form.value.claimNumber);
  }
  </code></pre>