How we can set Http Request Header in Angular 2 and Angular 4?
To set Http Request Header in Angular 2, create the HTTP Client Injectable class and inject the HttpClient object in the Component. Developers use HTTP Interceptors to set Http Request Header in Angular 4. To achieve this. Write an interceptor for adds a header for every request and after creating the interceptor, register it using HTTP_INTERCEPTORS
in the @NgModule()
.
Related Article: AngularJS vs. Angular 2 vs. Angular 4: What's the Difference
BY Best Interview Question ON 02 Feb 2020