In HttpClientModule, is there a method to pass headers and params to get request.
import { HttpHeaders, HttpParams, HttpClient } from @angular/common/http';
const headers = { headers: new HttpHeaders({}) }
let params = new HttpParams({ });
get(url, {params}) // http client get with params
get(url, {headers}); //http client get with headers
I want something like requestoptions to hold both or a syntax to do httpClient get sending request headers and params.
Currently building complete url with search params and sending headers along.
As of Angular 5.0.0-beta.6 (2017-09-03), you can now pass in both headers and parameters using the below syntax:
Source: https://github.com/angular/angular/pull/18490
Here is something that passes both headers and parameters in with a
get
, and it usesHttpParamsOptions
to serialize an object into parameters that the HttpClient can cope with.