Consider the following method:
public login(data:any): Observable<any> {
this.http.get('https://api.myapp.com/csrf-cookie').subscribe(() => {
return this.http.post('https://api.myapp.com/login', data);
});
}
I want to modify it so that the nested observable is returned, allowing the calling code to be structured as follows:
this.apiService.login(credentials).subscribe(() => {
// redirect user to their dashboard
});
The goal is for the inner HTTP request to wait for the outer one to complete and be included in the return value of the method. Currently, the above implementation does not achieve this.