title: Node js async convert to sync
body: <p>I need to push data to array synchronously. First API request get image key base one that need to get image data within loop.</p>
  
  <pre><code> var deasync = require('deasync');
  
  
          router.get('/a', function(req, res) {
                  var username="user";
                  var passw ="pass";
                  var op = [];
                  var args = {
                      headers: {
                      'Authorization': 'Basic ' + new Buffer(username + ':' + passw).toString('base64')
                  }   
              };
           //this is first api request
          client.get(global.apiUrl+"V1/ProductItem", args,
          function (data, response) {
                  //this is second api request
              data.forEach(function(img) {client.get(global.apiUrl+"V1/ImagePreview/"+img.AvatarKey,args,
                      function (data2, response){
                                 img['data']=data2.Image;
                                 deasync(pushData(img));
                            });
                      });     
                  });
  
          function pushData(img){
              op.push(img);//array push 
          }
          res.render('test1', { "out":JSON.stringify(op) });
          });
  </code></pre>