I just set up my headers like this and it worked for me:
const authorizationData = 'Bearer ' + user.accessToken;
const headerOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: authorizationData
})
};
if your have username and password to send, you can use this also:
const authorizationData = 'Basic ' + btoa(this.key + ':' + this.key);
const headerOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: authorizationData
})
};
After setting headers, pass it to httpClient something like this:
this.httpClient.get(url,
headerOptions).subscribe(res => {
console.log(res);
}, err => {
console.log(err);
});