title: ReferenceError: context is not defined
body: <p>I am trying to create a sendNotification function by using node.js and firebase function but unfortunately I am currently stuck. I never got a notification from the sender and when I look to Firebase function logs, I saw an error says</p>
  
  <pre><code>ReferenceError: context is not defined
  at exports.sendNotification.functions.database.ref.onWrite.event (/user_code/index.js:9:32)
  at Object.&lt;anonymous&gt; (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
  at next (native)
  at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
  at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
  at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:82:36)
  at /var/tmp/worker/worker.js:700:26
  at process._tickDomainCallback (internal/process/next_tick.js:135:7)
  </code></pre>
  
  <p>this is my code index.js code</p>
  
  <pre><code>`const functions = require('firebase-functions');
   const admin = require('firebase-admin');
   admin.initializeApp(functions.config().firebase);
   exports.sendNotification = functions.database.ref('notifications/{user_id}').onWrite(event =&gt; {
  
  const user_id = context.params.user_id;
  const notification_id = context.params.notification_id;
  
  console.log('We have notification from: ', user_id);
  
  if (!event.val()) {
      return console.log('A Notification has been deleted from the database: ', notification_id);
  }
  
  const fromUser = admin.database().ref(`/Users/${user_id}/device_token`).once('value');
  
  return fromUser.then(result =&gt; {
  
      const token_id = result.val();
  
      const payload = {
          notification: {
              title: "Friend Request",
              body: "You've received a Friend Request",
              icon: "default"
          }
      };
  
      return admin.messaging().sendToDevice(token_id , payload).then(response =&gt; {
  
          console.log('This was the notification feature');
  
      });
  
  });
  
  });
  </code></pre>
  
  <p>I don't know where is the error here can someone tell me where is the error and how can I resolve it?</p>