Seeking a solution to return an Observable nested within another Observable. Although I've tried using the pipe and map operators, it doesn't appear to be functioning correctly for me. What could be causing the issue?
My development environment includes Angular 9.1.12 and rxjs ~6.5.4.
For instance:
Service1import { Observable, of } from 'rxjs';
export class Service1 {
test(): Observable<string> {
console.log(1);
return of('hey');
}
}
Service2
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
export class Service2 {
constructor(private service1: Service1) {}
test(): Observable<string> {
return this.service1.test().pipe(
map((value: string) => {
console.log(2);
return value;
})
);
}
}
Component
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
export class Component implements OnInit {
constructor(private service2: Service2) {}
test(): Observable<void> {
return this.service2.test().pipe(
map((value: string) => {
console.log(3);
}));
}
}
}
Only "1" is displayed in the console.