Javascript firebase节点js类型错误:无法读取属性';toId';出口处未定义的
您好,是NodeJS的新成员 在我的firebase云函数日志中 它说它无法读取属性toId 我正在打印console.log(event),通配符toId显示了我检查时用户的UID,那么我做错了什么 这是我的密码:Javascript firebase节点js类型错误:无法读取属性';toId';出口处未定义的,javascript,node.js,firebase,google-cloud-functions,Javascript,Node.js,Firebase,Google Cloud Functions,您好,是NodeJS的新成员 在我的firebase云函数日志中 它说它无法读取属性toId 我正在打印console.log(event),通配符toId显示了我检查时用户的UID,那么我做错了什么 这是我的密码: exports.sendMessageNotification = functions.database.ref('/user-messages-notification/{toId}/{fromId}/{message}') .onCreate((snap, contex
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);
});
})
字符串“告诉”不会出现在代码中的任何地方。我看不出错误消息与它有什么关系。var toId=context.params.toId?对不起,我以为您键入的是“告诉”而不是“toId”(ell而不是eye)。未出现在搜索中。您使用的firebase函数的版本是什么?firebase实时数据库最新版本