I am looking for a way to return an Observable from another Observable. I found that you can do that using pipe and map operators, but it does not seem to be working for me. What am I doing wrong ?
I am using Angular 9.1.12 and rxjs ~6.5.4.
Example: Service1
import { 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);
      }));
    }
  }
}
The console will only output 1.
 
     
     
    