Ajouter angulaire httpclient

import { HttpClientModule } from '@angular/common/http';
// if you use services just import this
import { HttpClient } from '@angular/common/http';
//................................................
@NgModule({
  imports: [
    BrowserModule,
    // import HttpClientModule after BrowserModule.
    HttpClientModule,
  ],
  
  // in you component.ts
  readonly ROOT_URL = "https://jsonplaceholder.typicode.com";
  
 constructor( private http: HttpClient) { }
  
  this.http.get(this.ROOT_URL + '/posts')
    .subscribe((response)=>{
      alert(JSON.stringify(response));
    });

// send information

this.http.post(this.ROOT_URL + '/posts',
              { id: 1, title: "sami"} )
    .subscribe((response)=>{
      alert(JSON.stringify(response));
    });

// update

this.http.put(this.ROOT_URL + '/posts')
    .subscribe((response)=>{
      alert(JSON.stringify(response));
    });

// fetch

// delete
  
Mohamed Sami khiari