error
ReferenceError: functions is not defined at Object. (C:\Users\CROWDE~1\AppData\Local\Temp\fbfn_9612Si4u8URDRCrr\index.js:5:21) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at C:\Users\crowderia\AppData\Roaming\npm\node_modules\firebase-tools\lib\triggerParser.js:18:11 at Object. (C:\Users\crowderia\AppData\Roaming\npm\node_modules\firebase-tools\lib\triggerParser.js:32:3)
index.js file like below
'use strict'
const funnctions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.database.ref('/Notifications/{user_id}/{notification_id}').onWrite(event => {
const user_id = event.params.user_id;
const notification_id = event.params.notification_id;
cosole.log('User id is : ', user_id);
if (!event.data.val()) {
return console.log('A Notification has been deleted from the database : ', notification_id);
}
const deviceToken = admin.database().ref(`/Users/${user_id}/device_token`).once('value');
return deviceToken.then(result => {
const token_id = result.val();
const payload = {
notification: {
title: "Friend Request",
body: "You've received a new Friend Request",
icon: "default",
}
};
return admin.messaging().sendToDevice(token_id, payload).then(response => {
console.log('this is the notification feature');
});
});
});