Search code examples
angularangular-httpclient

I get HttpErrorResponse error when logging in on angular 11. Status 200


enter image description here

I am getting an error like this. Couldn't find the solution.

enter image description here

  login(signInRequestPayload: SignInRequestPayload): Observable<boolean> {
return this.httpClient.post<SignInResponse>( '/api/v1/registration/login', signInRequestPayload)
  .pipe(map(data => {
    this.localStorage.store('token', data.token);
    return true;
  }));

}


Solution

  • You might be receiving text as the response type, but by default Angular expects JSON. Try setting {responseType: 'text'} in the options of the call