Complete the code to import the HttpHeaders class.
import { HttpClient, [1] } from '@angular/common/http';
The HttpHeaders class is imported from @angular/common/http to set HTTP headers.
Complete the code to create a new HttpHeaders object with a custom header.
const headers = new HttpHeaders().set('[1]', 'application/json');
The Content-Type header tells the server the format of the data sent.
Fix the error in setting multiple HTTP params.
const params = new HttpParams().[1]('page', '1').append('limit', '10');
The append method adds a new value without replacing existing ones, allowing chaining.
Fill both blanks to create headers and params for an HTTP GET request.
this.http.get(url, { headers: new HttpHeaders().[1]('Authorization', 'Bearer token'), params: new HttpParams().[2]('search', 'angular') });Use set to set the Authorization header and append to add a search param.
Fill all three blanks to create headers and params with multiple values.
const headers = new HttpHeaders().[1]('Accept', 'application/json'); const params = new HttpParams().[2]('page', '2').[3]('limit', '20');
Headers use set to assign 'Accept'. Params use append twice to add 'page' and 'limit'.
