Angular 6 HttpErrorResponse on POST with 200 status
In Angular 11+ use httpOptions = { responseType: 'text' as const, }
By default, the Angular HttpClient tries to parse the body of the HTTP response as JSON. Since the response body that you are receiving is plain text, e.g. "Bearer .....", and not JSON, the JSON parse is failing.
You need to tell the HttpClient to expect a plain text response, like this:
this.httpClient.post(this.apiURL + '/login', user, {headers:reqHeader, responseType: 'text'});
Also note that since the response is a string, you should not be trying to cast it to a User (don't do the <User>
bit); The outgoing message is the User, the return value is a string.