1. Here is the my app.component.ts file code, in which I am sending body parameters and headers:

...
import { HttpClient, HttpHeaders } from '@angular/common/http';
...
export class AppComponent {
...
constructor(private http: HttpClient)
{
  // OBJECT WHICH WILL PASS BODY PARAMETERS
  var myFormData = new FormData();
  //Headers
  const headers = new HttpHeaders();
  headers.append('Content-Type', 'multipart/form-data');
  headers.append('Accept', 'application/json');
  //Body Paramenters
  myFormData.append('image', this.filedata);
  //HTTP POST REQUEST
  this.http.post('http://localhost/blog/public/api/sample-restful-apis', myFormData, {
  headers: headers
  }).subscribe(data => {
     //api response
      });
}
...
}

This is it and if you have any kind of query then please do comment below.

#angular 8 #angular 9 #angular7

Angular 9 - Http request with body and headers
63.80 GEEK