http post formdata png angular code example
Example: angular post form data to api
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';
constructor(private http: HttpClient) { }
ngOnInit() {
let headers = new HttpHeaders({
'Content-Type': 'application/json'});
let options = { headers: headers };
const body = { title: 'Angular POST Request Example' };
this.http.post<any>('https://reqres.in/api/posts', body, options).subscribe(data => {
this.postId = data.id;
});
}