title: Why can't I send SendGrid email from Lambda Function?
body: <p>I'm struggling to understand why my Lambda won't send this Sendgrid message.</p>
  
  <p>When I invoke the Lambda, I get console.log 1,2,3 in that order as well as null from the Sendgrid invocation. The Sendgrid promise callbacks are never invoked. Any idea why?</p>
  
  <pre><code>"use strict";
  
  const sendgrid = require('@sendgrid/mail');
  
  sendgrid.setApiKey('xxxxxxxxx');
  
  module.exports.scan = async (event, context, onComplete) =&gt; {
    console.log('1');
  
    await (() =&gt; {
      console.log('2');
      sendgrid.send({
        to: 'xxxxxxx',
        from: 'xxxxxxxxx',
        subject: 'Sending with SendGrid is Fun',
        text: 'and easy to do anywhere, even with Node.js',
        html: '&lt;strong&gt;and easy to do anywhere, even with Node.js&lt;/strong&gt;',
      })
      .then(() =&gt; {
        console.log('cool');
        onComplete(null, "successfully updated form next_scheduled")
      })
      .catch(error =&gt; {
        console.log('error');
  
        //Log friendly error
        console.error(error.toString());
  
        //Extract error msg
        const {message, code, response} = error;
  
        //Extract response msg
        const {headers, body} = response;
  
        onComplete(error, "failed to updated form next_scheduled")
      });
    })();
  
    console.log('3');
  };
  </code></pre>