Firebase云函数onWrite子值
我正在使用Firebase Cloud函数在实时数据库触发事件时发送FCM。如何获取{followerUid}中的子级('uid')的值Firebase云函数onWrite子值,firebase,google-cloud-functions,Firebase,Google Cloud Functions,我正在使用Firebase Cloud函数在实时数据库触发事件时发送FCM。如何获取{followerUid}中的子级('uid')的值 exports.sendFollowerNotification = functions.database.ref('/followers/{followedUid}/{followerUid}').onWrite(event => { const followerUid = event.params.followerUid; const fol
exports.sendFollowerNotification = functions.database.ref('/followers/{followedUid}/{followerUid}').onWrite(event => {
const followerUid = event.params.followerUid;
const followedUid = event.params.followedUid;
我不确定我是否明白你想做什么,但我会试试看 如果您希望访问触发该功能的节点内的
uid
数据:
var uid = event.data.child("uid").val;
看看。我完全知道你在找什么
var uid = event.data.val();
var uid1 = String(uid);
将此uid1添加到标题或正文
const payload = {
notification: {
title: paypes
body: uid1
}
};
由于API最近的变化。 下面给出了数据值
event.before.val();
或
作为onWrite(),在实时数据库中创建、更新或删除数据时触发。
所以它给出了before和after值。我得到了event.data.val()作为字典。在这种情况下,我如何解析??我是说我有好几个孩子。
event.after.val();