In my project, I am utilizing Angular 10. Within this project, I have implemented two functions named initData1 and initData2.
These are the two functions:
initData1(){
// Perform HTTP client services
this.dataService.getTitleImageUrl(this.data.titlId, this.data.id )
.subscribe( resp => { this.titleImageUrl = encodeURI(resp.results[0]) });
this.storeService.getContactImageUrl(this.store.titlId, this.store.id)
.subscribe( resp => { this.contactImageUrl = encodeURI(resp.results[0]) });
}
initData2(){
// Implement additional HTTP client services
this.dataService.getTitleImageUrl(this.data.titlId, this.data.id )
.subscribe( resp => { this.titleImageUrl = encodeURI(resp.results[0]) });
this.storeService.getContactImageUrl(this.store.titlId, this.store.id )
.subscribe( resp => { this.contactImageUrl = encodeURI(resp.results[0]) });
}
The execution of these functions in my component is as follows:
ngOnInit(): void {
initData1();
initData2();
}
I am currently seeking a solution on how to ensure that the initData2 function is only executed after all HTTP client services are resolved in the initData1 function.
UPDATE: Included examples of HTTP client services for better understanding.