I have the following issue with this function:
private async findOrCreatePanel(serviceId: string): Promise<Panel> {
await this.panelService.getActivePanels().subscribe(activePanels => {
const existingPanel = activePanels.find(panel => panel.serviceId === serviceId)
if (existingPanel) {
return existingPanel;
}
});
await this.panelService.addActiveFromService(serviceId).subscribe(newPanel => {
return newPanel;
});
return
}
Instead of waiting for await to finish, it goes very fast to the last return and it returns null, how could I fix this?