这个问题比较常见,但我相应地修改了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仍未定义?