title: Firebase cloud functions - Function returned undefined, expected Promise or value
body: <p>I've read thru the other threads and tried to return something to my cloud functions, but it still gives the same Function returned undefined, expected Promise or value warning... What am I missing here?</p>
  
  <p>Basically, I'm sending two emails out using mailgun-js to the user and to the admin, even though the sending is successful and stuff, I still get the same warning in my logs.</p>
  
  <pre><code>exports.sendSample = functions.database
  .ref( 'sample/{pushID}' )
  .onWrite( event =&gt; {
  
      //  only trigger if it's new
      if ( !event.data.exists() || event.data.previous.exists() ) return 0
  
      const e = event.data.val()
  
      const toUser = {
          to      : `${ e.email }`,
          from    : `xxx`,
          subject : `xxx`,
          html    : `xxx`
      }
  
      const toAdmin = {
          to      : `${ e.admin }`,
          from    : `xxx`,
          subject : `xxx`,
          html    : `xxx`
      }
  
      //  send sms
      if ( e.mobile !== 'none' ) {
          return client.messages.create({
              body : `xxx`,
              to   : `${e.mobile}`,
              from : `xxx`
          })
          .then( message =&gt; {
              sendEmail()
              return message.sid
          })
          .catch( err =&gt; {
              return err
          })
      } else {
          sendEmail()
      }
  
      //  send email
      function sendEmail() {
          if ( e.email !== 'none' ) {
              return mailgun.messages().send( toUser, ( err, body ) =&gt; {
                  return ( err, body )
                  return mailgun.messages().send( toAdmin, ( err, body ) =&gt; {
                      return ( err, body )
                  })
              })
          } else {
              return true
          }
      }
  })
  </code></pre>