title: How to use foreach and promise
body: <p>I need to get datas with nested foreach, but I can't fill my array.
  At the end of this code I would like to have an array (segId) with my datas but it is empty (because of aynschronous).
  I read that I had to use Promise.all but I can't beacause my promise are nested
  I'm beginner so my code is far from perfect
  How can I do that ?</p>
  <pre><code>    async function getActivities(strava, accessToken)
  {
    const payload = await strava.athlete.listActivities({'access_token':accessToken, 'after':'1595281514', 'per_page':'10'})
    return payload;
  }
  async function getActivity(strava, accessToken, id)
  {
    const payload = await strava.activities.get({'access_token':accessToken, 'id':id, 'include_all_efforts':'true'})
    return payload;
  }
  async function getSegment(strava, accessToken, id)
  {
    const payload = await strava.segments.get({'access_token':accessToken,'id':id})
    return payload
  }
  
  var tableau = []
  var segId = []
  const activities = getActivities(strava, accessToken)
  
  activities.then(value =&gt; {
    value.forEach((element, index) =&gt; {
      const activity = getActivity(strava, accessToken, element['id'])
      activity.then(value =&gt; {
        value['segment_efforts'].forEach((element, index) =&gt; {
          const segment = getSegment(strava, accessToken, element['segment']['id'])
          segment.then(value =&gt; {
            segId.push(value['id'])
          })
          //console.log(segId)
        });
      });
    })
  }) console.log(segId)
  </code></pre>
  <p>Regards
  PS : Sorry for my english ...</p>