title: Function returned undefined, expected Promise or value. although i am returning snapshot.val();
body: <p>I am writing a cloud function for my project . its being last 12 hours that i am stuck with this error "Function returned undefined, expected Promise or value"
  i have tried alot to remove it but not able to find how to solve it</p>
  
  <pre><code>exports.Notify = functions.database.ref('blood_share/Notifications/{user}/{notificationid}').onWrite((change, context) =&gt; {
  
          const username=context.params.user;
          const notifyid=context.params.notificationid;
  
  
          const query = admin.database().ref("blood_share/Notifications").child(username).child(notifyid);
          query.once('value').then(snapshot=&gt;{
           const event = snapshot.val();
  
          const notificationMessage = event.messsage;
          const token_id=event.reciever_appid;
          console.log("message"+notificationMessage);
  
  
  
          //create notification Json
  
          const payLoad = {
         notification:{
           title: "New Request For Food",
           body: "kuch b",
           icon: "default"
         }
       };
  
        return snapshot.val();
  
           }).catch(error =&gt; {
           console.error(error);
  
           });    
  
     });
  </code></pre>