Complete the code to import the Angular HTTP client module.
import { HttpClientModule } from '@angular/common/http'; @NgModule({ imports: [[1]] }) export class AppModule {}
You need to import HttpClientModule in your Angular module to use HTTP services.
Complete the code to inject HttpClient into the constructor.
constructor(private [1]: HttpClient) {}The injected variable name should be a lowercase descriptive name like http.
Fix the error in the POST request method call.
this.http.[1]('https://api.example.com/data', payload).subscribe(response => { console.log(response); });
To send data to the server, use the post method of HttpClient.
Fill both blanks to add headers and handle the POST request.
const headers = new HttpHeaders().set('[1]', '[2]'); this.http.post('https://api.example.com/data', payload, { headers }).subscribe();
Set the Content-Type header to application/json to tell the server the data format.
Fill all three blanks to create a POST request with typed response and error handling.
this.http.post<[1]>('https://api.example.com/data', payload).subscribe({ next: (data) => console.log(data.[2]), error: (err) => console.error('Error:', [3]) });
Specify the expected response type User, access the name property, and log the error message.
