should I use the httpclient modular in angular to make post calls but in this case the call is not carried out what is due?
app.component.html:
<div class="col-xs-12">
<button class="btn btn-primary" (click)="getData()">Chiamata rest</button>
</div>
app.component.ts:
import { Injectable,Component, OnInit ,DoCheck} from '@angular/core';
import { HttpClient,HttpHeaders } from '@angular/common/http';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
getData(){
const body = JSON.stringify({firstName: 'Joele', lastName: 'Smith4'});
return this.http.post('http://localhost:8787/utente/nuovoutente', body, httpOptions);
}