Firebase函數(shù):無(wú)法讀取未定義的屬性“user_id”我試圖用我的移動(dòng)應(yīng)用程序做一個(gè)簡(jiǎn)單的hello world firebase功能,我想記錄用戶ID,這樣我就可以看到該功能確實(shí)有效。這是我目前的javascript代碼:const functions = require('firebase-functions');const admin = require('firebase-admin');admin.initializeApp(functions.config().firebase);exports.sendNotification = functions.database.ref('/notifications/{user_id}').onWrite((event) => {
console.log('Testing stuff', event.params.user_id);
return;});當(dāng)新數(shù)據(jù)寫(xiě)入特定數(shù)據(jù)庫(kù)表時(shí)會(huì)觸發(fā),但會(huì)顯示以下錯(cuò)誤:TypeError: Cannot read property 'user_id' of undefined
at exports.sendNotification.functions.database.ref.onWrite (/user_code/index.js:8:44)
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:700:26
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
- 1 回答
- 0 關(guān)注
- 412 瀏覽
添加回答
舉報(bào)
0/150
提交
取消