title: Function returned undefined, expected Promise or value Firebase log error
body: <p>Im trying to add a push notification on my app using firebase-function and node.js and all its all working fine, like I got notification from the sender. but my only concern is that the log gave me this error</p>
  
  <pre><code>Function returned undefined, expected Promise or value 
  </code></pre>
  
  <p>and this is my code:</p>
  
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp();
  
  exports.sendNotification = functions.database.ref('/notifications/{user_id}/{notification_id}').onWrite((change, context) =&gt; {
  
      const user_id = context.params.user_id;
      const notification_id = context.params.notification_id;
  
      console.log('We have a notification : ', user_id);
  
      const afterData = change.after.val();
  
      if (!afterData){
          return console.log('A notification has been deleted from the database', notification_id);
      }
  
      const fromUser = admin.database().ref(`/notifications/${user_id}/${notification_id}`).once('value');
      return fromUser.then(fromUserResult =&gt; {
  
          const from_user_id = fromUserResult.val().from;
  
  
          console.log('You have a new notification from: ', from_user_id);
  
          const deviceToken = admin.database().ref(`/Users/${user_id}/device_token`).once('value');
  
          return deviceToken.then(result =&gt; {
  
              const token_id = result.val();
  
              const payload = {
                  notification: {
                      title: "New Friend Request",
                      body: "You've received a new Friend Request",
                      icon: "default"
                  }
              };
  
              return admin.messaging().sendToDevice(token_id, payload).then(response =&gt; {
                  console.log('This was the notification feature');
              });
  
          });
  
      });
  
  });
  </code></pre>
  
  <p>what should I return here and where it will be place? I am currently using the latest firebase CFM version 1.0</p>