Looking for a solution to create a wrapper service for Angular 2's Http Service that can save the returned Headers without altering the original Observable? The main goal is to make any call to an Angular 2 Http method (e.g. http.get()
) and then retrieve the Response object contained in the observable without changing it. As far as I know, the only object within the returned Observable is the Response object itself. Below is an example of how this could be implemented in TypeScript:
private headers: Headers;
constructor(private http: Http) { }
public get(url: string): Observable<Response> {
return this.http.get(url, this.headers); // save the Response's headers before returning
}
I am still new to RXJS, so any advice on how to extract the Response while preserving the observable would be greatly appreciated. Ideally, I am looking for an efficient method that follows best practices with RXJS. Thank you.