title: Returning Output from AWS.DynamoDB.DocumentClient.Scan() Call
body: <p>I've got a function that returns the number of records from a DynamoDB table (Things):</p>
  
  <pre><code>const table = 'Things';
  const region = 'us-east-1';
  const profile = 'development';
  
  process.env.AWS_SDK_LOAD_CONFIG = true;
  process.env.AWS_PROFILE = profile;
  
  const AWS = require('aws-sdk');
  AWS.config.update({ region: region });
  
  function ddb_table_has_records(table_name) {
      const ddb_client = new AWS.DynamoDB.DocumentClient();
  
      const ddb_query_parameters = {
          TableName: table_name,
          Select: 'COUNT'
      }
  
      const results = ddb_client.scan(ddb_query_parameters).promise();
  
      results.then((data) =&gt; {
          console.log(data.Count);
          return data;
      }).catch((err) =&gt; {
          console.log("Error: ", err);
      })
  }
  
  console.log(ddb_table_has_records(table));
  </code></pre>
  
  <p>When I run this code, I get the following...</p>
  
  <pre><code>PS C:\&gt; node .\get-count-thing.js
  undefined
  3951
  </code></pre>
  
  <p>I'm not capturing the data from the scan in the following; although, I see it in the console.log() call:</p>
  
  <pre><code>console.log(ddb_table_has_records(table));
  </code></pre>
  
  <p>What am I mucking up?</p>