@maxkoch wrote:
Hey Ionites!
I have CustomerPage, CustomerService and AuthService.
In need to pass an access_token from AuthService to CustomerService for http-get request.
AuthService and CustomerService are not working(see comments).
Please help meCustomerPage:
this.customerService.getCustomersDashboard() .subscribe(....)
CustomerService:
getCustomersDashboard(): Observable<any> { var url = "......"; let authHeader = this.authservice.getAuthHeaders(); // HttpHeader with access_token return this.http.get(url, { headers: authHeader }).pipe( map((resp: Response) => { let response = this.extractData(resp); return response; }));
AuthService:
** is not working !!!**getAuthHeaders(){ const authtoken = Observable.fromPromise(this.storage.get(`access_token`)); return new HttpHeaders({ 'authorization': authtoken }); // => **not working** }
Posts: 2
Participants: 2