title: Javascript code not running in order while getting data from database
body: <p>I have two functions as shown below. It is essentially just getting data from a database.</p>
  <pre><code>function processRequest(query){
      let dynamoData = getDynamoData(query);
      console.log('abc')
  }
  
  
  function getDynamoData(key){
      var params = {
          TableName: 'test_table',
          Key: {
            'TWEET_KEY' : {S: String(key)}
          }
        };
        
        // Call DynamoDB to read the item from the table
        ddb.getItem(params, function(err, data) {
          if (err) {
              console.log(&quot;Error&quot;);
          } else {
              console.log(&quot;Successfully got data from table&quot;)
              return data.Item;
          }
        });
  }
  </code></pre>
  <p>Currently when I run the code, within the console it prints the following:</p>
  <pre><code>abc
  Successfully got data from table
  </code></pre>
  <p>However, I need it to print <code>Successfully got data from table</code> before it prints <code>abc</code>.</p>
  <p>I know I have to possibly use async within the function however am really struggling to get the code running in order. Would really appreciate it if anyone could help me get the code running in order. Thank you!</p>