Having issue with starting Firebase Function and a user_id is undefined
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.
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 [email protected] 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;
// ...