title: How to return results from async.js series
body: <p>Every example I see for async.js looks something like this:</p>
  
  <pre><code>var async = require(“async”);
  async.series([
    function(callback) {
      setTimeout(function() {
        console.log(“Task 1”);
        callback(null, 1);
      }, 300);
    },
    function(callback) {
      setTimeout(function() {
        console.log(“Task 2”);
        callback(null, 2);
      }, 200);
    },
    function(callback) {
      setTimeout(function() {
        console.log(“Task 3“);
        callback(null, 3);
      }, 100);
    }
  ], function(error, results) {
    console.log(results);
  });
  </code></pre>
  
  <p>At the end they always just console.log the results. But, how do you actually <em>return</em> the results. Every time I try it just comes back as undefined.</p>
  
  <p>I need something like this:</p>
  
  <pre><code>var async = require('async');
  
  var handler = function()
  {
    async.series([
    function(callback) {
      setTimeout(function() {
        console.log('Task 1');
        callback(null, 1);
      }, 300);
    },
    function(callback) {
      setTimeout(function() {
        console.log('Task 2');
        callback(null, 2);
      }, 200);
    },
    function(callback) {
      setTimeout(function() {
        console.log('Task 3');
        callback(null, 3);
      }, 100);
    }
    ], function(error, results) {
      return results;
    });
  }
  
  var result = handler();
  console.log(result);
  </code></pre>
  
  <p>But this doesn't work, the result is always undefined.</p>
  
  <p>Ultimately I need to put this up on AWS Lambda and return the results with their context.succeed(results) call. But, I can never get the results. I'm obviously not understanding something about this process, if someone could help it would be much appreciated, thanks!</p>