I have a component which uses a service that makes an HTTP call:
getTrendingTerms(): Observable<Object[]> {
return this.http.get(this.trendsUrl)
.map(this.mapResponse)
.catch(this.handleError);
}
private mapResponse(response: Response) {
let body = response.json();
return body || {};
}
and it works just fine.
However, I'm now introducing a new (unrelated to the first) component that will need to use that same data. Obviously I don't want to make a second HTTP call again, so what's the best strategy here? I'm very new to Angular 2 (and Observables) so this may be far simpler than I'm expecting ..