passing authorization header in typescript http request
import { HttpClient, HttpHeaders } from '@angular/common/http';
...
constructor(private http: HttpClient){}
...
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': environment.key
})
};
this.http.post(environment.APIUrl, httpOptions).subscribe(
response => {
console.log(response);
});
...