Здравствуйте, новый для узла Js
в журналах моей облачной функции firebase
он говорит, что не может прочитать свойство toId
Я печатаю console.log (событие) иподстановочный знак toId показывает UID пользователя, как я проверял, так что я делаю не так?
вот мой код:
exports.sendMessageNotification = functions.database.ref('/user-messages-notification/{toId}/{fromId}/{message}')
.onCreate((snap, context) => {
console.log('This is the event:',event)
var toId = context.params.toId
var fromId = context.params.fromId
console.log('User: ' + toId + ' recieved a message from ' + fromId);
var userRef = db.collection('Users').doc(toId);
var getDoc = userRef.get()
.then(doc => {
if (!doc.exists) {
return console.log('No such document!');
} else {
var User = doc.data();
return console.log('Document data:', doc.data());
}
})
.catch(err => {
//catch error does not need 'return console'
console.log('Error getting document', err);
});
})