title: Lambda function skipping SNS publish call
body: <p>im currently trying to send a push notification from AWS Lambda but the following code is getting skipped in my function as i tried to output something within and its not showing.
  Please help me</p>
  <pre><code>const AWS = require(&quot;aws-sdk&quot;);
  const documentClient = new AWS.DynamoDB.DocumentClient();
  const sns = new AWS.SNS();
  AWS.config.region = 'ap-southeast-1'
  
  exports.handler = async event =&gt; {
    const params = {
      TableName: &quot;Items&quot; // The name of your DynamoDB table
    };
    try {
      // Utilising the scan method to get all items in the table
      const data = await documentClient.scan(params).promise();
      var allItems = data.Items;
      allItems.forEach(async function (item){
          const tempItem = item;
          var endDate = new Date(tempItem.endDate);
          var today = new Date();
          today.setHours(0, 0, 0, 0);
          var currentDaysLeft = endDate - today;
          if (currentDaysLeft &lt; 0)
          {
              currentDaysLeft = 0;
          }
          
          // convert JS date milliseconds to number of days
          currentDaysLeft = Math.ceil(currentDaysLeft / (1000 * 60 * 60 * 24)); 
          
          if (tempItem.durationLeft != currentDaysLeft){
              tempItem.durationLeft = currentDaysLeft;
          }
          
          const message =  tempItem.username + &quot;'s &quot; + tempItem.title + &quot; is expiring in &quot; + tempItem.durationLeft + &quot; days.&quot; ;
  
          const msgparams = {
            Message: message,
            TopicArn: 'arn:aws:sns:ap-southeast-1:xxxxxxxxx:xxxxx'
          };
          var publishPromise = sns.publish(msgparams).promise();
          
      });
      return;
    } catch (e) {
      return {
        body: e
      };
    }
  };
  </code></pre>
  <p>I have tested that the for each loop runs correctly based on the number of items returned and that the data from the scan is all indeed correct, but the publish part is not running</p>
  <p>this is my code for firebase messaging service</p>
  <pre><code>public override void OnMessageReceived(RemoteMessage message)
          {
              base.OnMessageReceived(message);
              string messageBody = string.Empty;
  
              if (message.GetNotification() != null)
              {
                  messageBody = message.GetNotification().Body;
              }
  
              // NOTE: test messages sent via the Azure portal or AWS SNS portal will be received here
              else
              {
                  messageBody = message.Data.Values.First();
              }
  
              // convert the incoming message to a local notification
              SendLocalNotification(messageBody);
          }
  </code></pre>