0

I'm trying to unsubscribe but it's not working where I'm having one api response inside making another api call.

 this.sub = this.dataSevice.gerApp("true").pipe(switchMap(res)=> return this.dataService.getAppTwo("empty")). subscribe((res)=>console.log(res));

ngOnDestroy(){
this.sub.unsubscribe();
}
ajai
  • 187
  • 1
  • 2
  • 15
  • If your observables are created by httpClient, then they will be automatically unsubscribed on completion. https://stackoverflow.com/questions/35042929/is-it-necessary-to-unsubscribe-from-observables-created-by-http-methods – huan feng Sep 13 '22 at 02:53

1 Answers1

0

HTTPClient will emit only once. HTTPClient is a finite observable, so it is self completed. No need to worry about unsubscribe.