Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase云函数onWrite子值_Firebase_Google Cloud Functions - Fatal编程技术网

Firebase云函数onWrite子值

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

我正在使用Firebase Cloud函数在实时数据库触发事件时发送FCM。如何获取{followerUid}中的子级('uid')的值

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();