TypeError:无法读取属性' user_id'未定义的新版本

时间:2018-06-17 21:12:06

标签: javascript node.js firebase firebase-cloud-messaging google-cloud-functions

这个问题比较常见,但我相应地修改了v 1.0的新版本代码。 .. 通常,代码必须根据新版本工作。但它没有,我问为什么它可能

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

exports.sendNotification = functions.database.ref('/notifications/{user_id}/{notification_id}')
.onWrite((change, context) => {

  //const user_id = context.params.user_id;
  //const notification = context.params.notification_id;

  console.log('The User Id is : ',context.params.user_id);
});

这是错误

TypeError: Cannot read property 'user_id' of undefined
at exports.sendNotification.functions.database.ref.onWrite.event (/user_code/index.js:7:31)
at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
at next (native)
at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:82:36)
at /var/tmp/worker/worker.js:716:24
at process._tickDomainCallback (internal/process/next_tick.js:135:7)

这是我的数据库 numpy.moveaxis

为什么user_id仍未定义?

0 个答案:

没有答案