title: JavaScript how to splice in that case
body: <ul>
  <li>the frontend fetches activities from the API</li>
  <li>users can write comments to an activity</li>
  <li>I want to fetch the comments after clicking on a button</li>
  </ul>
  
  <p>The code generates 2 calls:</p>
  
  <ol>
  <li>get the activities and store them in the variable activities.</li>
  <li><p>get the commentCount from a different endpoint</p>
  
  <pre><code>    //get activities
      dsActivity.getActivities(query)
          .then(function (items) {
              var activities = items.plain();
  
              for (var i = 0; i &lt; activities.length; i++) {
  
                  //get totalComment count
                  dsActivity.getActivityCount(activities[i].id)
                      .then(function (result) {
                          var totalComments = result.plain();
                          activities = totalComments;
                      }.bind(this));
  
                  this.items.push(activities);
              }
              if (this.offset &lt; items.meta.page_count) {
                  this.offset += 1;
              } else {
                  return;
              }
              this.busy = false;
          }.bind(this));
  </code></pre></li>
  </ol>
  
  <p>It's currently not possible to include this field in the activitiy endpoint of the api. That's the reason why I want to put them together by using JS.</p>
  
  <p><strong>DATA STRUCTURE</strong></p>
  
  <p><strong>var activities:</strong>
  here are the activities</p>
  
  <p>{
    "text": "first activity",
    "privacy": null,
    "createdAt": {
      "date": "2015-10-27 00:16:24.000000",
      "timezone_type": 3,
      "timezone": "Europe/Berlin"
    },
    "id": 1,
    "comments": {},
  }</p>
  
  <p><strong>var totalComments</strong>
  here is the commentCount</p>
  
  <p>{
    "comments": {
      "total_items": 6
    }
  }</p>
  
  <ul>
  <li>How can I put the following data structures together in one array?</li>
  </ul>