title: Async callback nodejs
body: <p>I try to use async NodeJs library to execute a render with express after collecting informations of a API but the async.parallel callback execute itself before collecting all data that I need</p>
  
  <p>This is the code : </p>
  
  <pre><code>            LolApi.getMatchHistory(app_dtb.summoner.id, "euw", function(err, history) {
              if (!err) {
                  async.parallel([
                      function(callback) {
                          LolApi.getMatch(history.matches[nbMatch].matchId, function(err, match) {
                              if (!err) {
                                  var teamIn;
  
                                  function getParticipantNb() {
                                      for (var i = 0; i &lt; match.participantIdentities.length; i++) {
                                          if (app_dtb.summoner.id == match.participantIdentities[i].player.summonerId) {
                                              if (i &lt;= 5) teamIn = 100
                                              else teamIn = 200
                                              return i + 1
                                          }
                                      }
                                      return false;
                                  }
  
                                  var participantNb = getParticipantNb()
                                  if (match.teams[0].winner == true &amp;&amp; teamIn == 100) {
                                      app_dtb.lastGame.won = "Win";
                                  } else {
                                      app_dtb.lastGame.won = "Loose";
                                  }
                                  console.log(app_dtb.lastGame.won)
                              } else {
                                  console.log(err)
                              }
  
                          });
                          setTimeout(function() {
                              callback(null, "one");
                          }, 200);
                      },
                      function(callback) {
                          options = {
                              champData: 'allytips,blurb',
                              version: '4.4.3',
                              locale: 'en_US'
                          }
                          LolApi.Static.getChampionById(history.matches[nbMatch].champion, options, function(err, champ) {
                              if (!err) {
                                  console.log(champ.name);
                                  app_dtb.lastGame.champName = champ.name
  
                              } else {
                                  console.log(err)
                              }
  
                          });
                          setTimeout(function() {
                              callback(null, "two");
                          }, 100);
                      }
                  ], function(err, results) {
                      console.log(results)
                      res.render("index");
                  });
              } else {
                  console.log(err);
              }
  
          })
  </code></pre>
  
  <p>Any idea or other way to have the same result ? </p>
  
  <p>Thanks a lot</p>