title: I unable to return Async function variable to caller function in node.js
body: <p>// this function will recieve array of two sets, containing youtube url and which will in turn call youtube oembed api and receive iframe and video properties, everything was working i am able to receive data from youtube api and convert into them array, but i am unable to pass to the caller function </p>
  
  <pre><code> function getWaterfall(data){
          var resultArr = [];
           function iter(datas, callback){    
          async.waterfall([
             function getData(callback){
             var link = nconf.get('youtubeuri')+encodeURIComponent(datas.src);
             console.log(link);
               http.get(link, function(res) {
              console.log("Got response: " + res.statusCode);
              res.on("data", function(chunk) {                   
                  var result = JSON.parse(chunk);
                   console.log(JSON.stringify(result));
                   callback(null, result)
                   });
          }).on('error', function(e) {
                callback(err);
              console.log("Got error: " + e.message);
            })  
          },
          function processData(results,callback){
              var sets = {};
                sets.videotitle = results.title;
                sets.videothumb_url= results.thumburl;
                sets.videoiframe= results.html;
                sets.videoheight= results.height;
                sets.videowidth= results.width;
                sets.videoauthor= results.author_name;
                sets.videoauthurl= results.author_url;
                callback(null,sets);                
              },
              function updateArray(resu, callback){
                   resultArr.push(resu);
                   console.log(resu);
                   callback(null);                    
           }
         ],
        function finalcall(){            
               console.log('operation completed');
               console.log(resultArr.length);
               console.log(JSON.stringify(resultArr));
               callback(null);    
           });         
    }
   async.each(data, iter, function(){                 
           console.log('array completed');
           console.log(resultArr.length);
           return resultArr;            
           console.log(JSON.stringify(resultArr));                    
      });       
   }
   // caller function 
    exports.uploadPaletteVideo = function(req,res){  
         Palette.findById(req.body.palid, function(err, videodoc){
                if(err){
                 util.log('palette with id not found video '+err);
              }else{               
   var mar = [{'src':'http://www.youtube.com/watch?v=k98k47X_Ugo'},    {'src':'https://www.youtube.com/watch?v=6OLsmfxalPw'}];
              console.log('the palette' + getWaterfall(mar));               
              //console.log('From PaletteVideo'+ JSON.stringify(youtube));              
             }                            
      }) 
   res.send('success');
  }      
  </code></pre>
  
  <p>my code unable to return array to caller function, but i am able to pass this array to another function and its working. please help me out..</p>