I\'m using Angular 4 for my client application.
The getCustomer() function in customer.service calls an API to get data. This function is Observable.
This
Off the top of my head, in your customer.service.ts
you can chain method calls with something like this:
getCustomer(id: string): Observable {
this.authService.getAccessToken()
.map((accessToken) => {
let headers = addAccessTokenToHeader(accessToken);
let url = `${this.customersUrl}/${id}`;
return this.http.get(url, { headers: headers })
// rest of the code
});
If it doesn't work, try replacing .map
with .switchMap
.