First, you need to add HttpHeaders with HttpClient
import { HttpClient,HttpHeaders } from '@angular/common/http';
your constructor should be like this.
constructor(private http: HttpClient) { }
then you can use like this
let header = new HttpHeaders({ "Authorization": "Bearer "+token});
const requestOptions = { headers: header};
return this.http.get<any>(url, requestOptions)
.toPromise()
.then(data=> {
//...
return data;
});