I have three services and each of them make a simple API call and return the value to the client, each API call depends of some data get from other.
Like the first Observable i'm subscribed get users data then with the data get from it i can call the Observable which gets the parameters by passing two values got from the first Observable, then the third Observable needs same data from the 1st Observable and one parameter got from the 2nd one.
So my code looks like this:
ngOnInit(): void {
this.profiloService
.profilo(this.idNegozio)
.subscribe((profilo: Profilo) => {
this.profilo = profilo;
this.menuService
.menu(profilo.idNegozio, profilo.piva, 'IT')
.subscribe((menu: Menu[]) => {
this.menu = menu;
this.pluService
.plu(profilo.idNegozio, profilo.piva, 'IT')
.subscribe((plus: Plu[]) => {
this.plus = plus;
this.filterPlu(menu.id);
});
});
});
}
Is it a good approach to subscribe to Observable from another observable? If not what should be the best practice?