title: RxJs Angular 7 HttpClient multiple POST with forkJoin remove second subscribe?
body: <p>I am creating a Work Item object with linked child Task objects.  My function (createWorkItemAndChildren) takes two parameters, the workItem, and an array of Task objects.  I want my function to return an array of all ids that are created (work item and tasks). </p>
  
  <p>I have to have the parent ID back from one http POST call (workItemService.createWorkItem) before I can then create the child tasks which use another http POST method on the same service.  </p>
  
  <p>I now have the forkJoin in createChildWorkItems returning all of the child ids at once.</p>
  
  <p>How do I refactor this so that there is only one subscribe, and to return the array with parent and child ids together?</p>
  
  <pre class="lang-js prettyprint-override"><code>  createChildWorkItems(parentId, tasks: Task[]): Observable&lt;any&gt; {
      return &lt;Observable&lt;number&gt;&gt; forkJoin(
        tasks.map(task =&gt; &lt;Observable&lt;number&gt;&gt; this.workItemService.createChildWorkItem(parentId, task))
      ).pipe(zip());
  
    }
  
    createWorkItemAndChildren(workItem, childTasksToSave: Task[]){
      var resultArray = [];
      this.workItemService.createWorkItem(workItem).subscribe(workItemId =&gt; {
        var parentId = workItemId;
        resultArray.push(parentId);
        if (parentId !== null){
          this.createChildWorkItems(parentId, childTasksToSave).subscribe((results: number) =&gt; {
            resultArray.push(results);
            this.tfsIdsCreated = resultArray;
          });
        }
      });
    }
  </code></pre>