Open Emahrb opened 6 years ago
i have facing same error how to resolve it?
still I have no perfect solution :( If I got something , I will let you :D
On Tue, Jun 19, 2018 at 11:24 PM shehryar Ahmed notifications@github.com wrote:
i have facing same error how to resolve it?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/211#issuecomment-398479256, or mute the thread https://github.com/notifications/unsubscribe-auth/AiZBRgx8RKpbQBBHAcBWBiu4RZkztISTks5t-TPdgaJpZM4UXmKs .
I am facing the same issue .
Have you tried to use the same way as in shown in doc?
// ...
.onWrite((change, context) => {
const user_id = context.params.user_id;
// ...
Here is my index.js file :
'use-strict'
const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.firestore.document("Users/{user_id}/Notification/{notification_id}").onWrite(event=> {
const user_id = event.params.user_id; const notification_id = event.params.notification_id;
console.log("User ID : "+ user_id + " | Notification ID : " + notification_id);
});
And, here is the Error :
Function execution took 1336 ms, finished with status: 'error'
TypeError: Cannot read property 'user_id' of undefined at exports.sendNotification.functions.firestore.document.onWrite.event (/user_code/index.js:8:31) at Object. (/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)