关于Firebase功能

时间:2018-06-07 13:36:07

标签: javascript firebase google-cloud-functions

我尝试将一个函数上传到firebase并尝试使用它。 这是我的代码

'use strict'
const functions = 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;
console.log('The User Id is ',user_id);

});

但是我在firebase中说错了......

  

TypeError:无法读取未定义的属性“user_id”       at exports.sendNotification.functions.database.ref.onWrite.event(/user_code/index.js:10:31)       在对象。 (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)       在下一个(本地)       at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71       在__awaiter(/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)       在cloudFunction(/user_code/node_modules/firebase-functions/lib/cloud-functions.js:82:36)``       在/var/tmp/worker/worker.js:716:24       at process._tickDomainCallback(internal / process / next_tick.js:135:7)

0 个答案:

没有答案