I have the following code:
ngOnInit(): void {
this.issueService.getIssues().pipe(
switchMap(issues => {
this.issuesList = issues;
const observables = this.issuesList.map(issue => this.issueService.getChildrenIssues(issue.id));
return forkJoin([observables]);
})
).subscribe(
(...results) => {
results.map((result, i) => {
this.childIssueMap.set(this.issuesList[i].id, result);
// error: Argument of type '[Observable<Issue[]>]' is not assignable to parameter of type 'Issue[]'.
});
}
);
}
Where:
public issuesList: Issue[];
public childIssueMap = new Map<string, Issue[]>();
I need to get all my issues from a server by calling the "getIssues()" first. Then, when I get them, for each of them I need to call a service "getChildrenIssues(parentId)" where I pass the issue id and I get all the children issue. Then I store the children issues in the childIssueMap by using the parent id as the key and the list of children issues as value.
I am not really sure how to do this. I tried to use forkJoin but my editor says it's deprecated, therefore I used the variation with [] but this time I am getting the error you see above.