title: Parse a POST request from Object to JSON
body: <p>I try to make a POST request to a server but I have an issue with Angular.
  It seems that the server receive the request but I still see an error in the Console suggesting to change the body from Object to JSON</p>
  <blockquote>
  <p>error: SyntaxError: <strong>Unexpected token A in JSON at position 0 at JSON.parse</strong> () at XMLHttpRequest.onLoad (http://localhost:4200/vendor.js:69142:51)
  text: &quot;A new user it was saved with id = : 23&quot;
  <strong>proto</strong>: Object
  headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
  message: &quot;Http failure during parsing for http://localhost:8191/api/user&quot;
  name: &quot;HttpErrorResponse&quot;</p>
  </blockquote>
  <p>In my cod for example I need to resolve this because I try to navigate to another page when I submit it.</p>
  <pre><code>createNewUser(user: User): Observable&lt;Object&gt;{
      return this.httpClient.post(`${this.createURL}`,user);
    }
  
    saveNewUser(){
      this.userService.createNewUser(this.user).subscribe( data =&gt;{
        console.log(data);
        this.router.navigateByUrl('/list-user');
      },
      error =&gt; console.log(error));
    }
  
  </code></pre>
  <p><strong>Solution for an older Angular version where it had @angular/http</strong>
  In the past for an older version of Angular, older then 10, I know that I was able to do it like below but now is not RequestOptions I can not import it because it need @angular/http:</p>
  <pre><code>addUser(user: User){
          let body = JSON.stringify(user);
          //pass the content type which is aoolication/JSON cintent
          let headers = new Headers({'Content-Type': 'application/json'});
          let options = new RequestOptions({headers: headers});
          //pass body and options
          return this._httpService.post(&quot;https://localhost:8443/api/user&quot;, body, options);
      }
  </code></pre>
  <p>Do you have any other solution?</p>