I'm facing an issue with my code where the API call in ngOnInit is not waiting for the data to be returned before moving on to ngAfterViewInit. I need it to wait because I am performing operations on that data in ngAfterViewInit, but currently, it's causing issues with my Dto being undefined. Any suggestions on how to ensure that the data is loaded and processed before proceeding?
this.subscriptions.add(
this.gridService
.GetGridByName(
this.gridName,
'1.0'
)
.subscribe({
next: (data: any) => {
if (data.result) {
// The code should wait for the DTO to load before moving to ngAfterViewInit
this.gridDto = data.result;
}
},