passing authorization header in typescript http request

Solutions on MaxInterview for passing authorization header in typescript http request by the best coders in the world

showing results for - "passing authorization header in typescript http request"
Irene
26 Jan 2018
1import { HttpClient, HttpHeaders } from '@angular/common/http';
2
3...
4constructor(private http: HttpClient){}
5...
6const httpOptions = {
7        headers: new HttpHeaders({
8          'Content-Type':  'application/json',
9          'Authorization': environment.key
10          })
11        };
12    this.http.post(environment.APIUrl, httpOptions).subscribe(
13      response => {
14      console.log(response);
15    });
16...