Problem to organize chain of calls by using rxjs observables with typescript
I am new in RXJS and have some trouble to organize chain of calls in my typescript code. Question is - how to make this.http.get('http://www.gooogle.com'); calling only once. This code is not real, just a minimum case for reproduce
import {Injectable} from '@angular/core';
import {flatMap, map} from 'rxjs/operators';
import {Observable, from} from 'rxjs';
import {HttpClient} from '@angular/common/http';
@Injectable()
export class CoolService {
constructor(private http: HttpClient) {}
x(): Observable<Object> {
return from(Promise.resolve({a: {b: 'c'}})).pipe(
flatMap((x) => {
console.log(x);
return this.http.get('http://www.gooogle.com');
}), map((res) => {
console.log(res);
return res;
}));
}
}