title: Read DB function - execution order
body: <p>I am reading a DB and output the result in a string.
  The issue is that sometimes the output is empty, my guess is that the function "json" is executed before the DB-read is completed.. I tried to apply "callback" which I read in other threads, but it didnt solve it.
  What am I doing wrong?</p>
  
  <pre><code>var response = {};
  var items = {};
  var table = "table";
  
  exports.handler = async (event) =&gt; {
  ReadDB(json);
  return response;
  };
  
  //**********************ReadDB Function
  function ReadDB(callback) {
  var paramsRead = {
    TableName: table,
  };
  
  // Call DB to read the item from the table
  ddb.scan(paramsRead, function(err, data) {
    if (err) {
      console.log("Error reading DynamoDB", err);
    } else {
        items = data.Items;
    }
  });
  
  callback(items);
  
  }
  
  //**********************json Function
  function json(items) {
    console.log(items);
      response = {
        body: JSON.stringify({items}, null, '\t'),
          };
          console.log(response);
  }
  </code></pre>