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
I'm using flatMap and it works now. Thank you very much for your suggestions @AJT_82
Off the top of my head, in your customer.service.ts
you can chain method calls with something like this:
getCustomer(id: string): Observable<CustomerResource> {
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
.