I'm trying to write a cloud function using node.js and I'm getting this error:
TypeError: Cannot read property 'user_id' of undefined at exports.FindRoom.functions.database.ref.onWrite (/user_code/index.js:299:39) at Object. (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
From this function:
exports.FindRoom = functions.database.ref(`/FindRoom/{user_id}`).onWrite((event) =>{
var user_id = event.params.user_id;
console.log("user_id",user_id);
var user_question = event.data.val();
console.log("user_question",user_question);
if (!event.data.val()) {
return console.log('A game room was deleted from database',user_id);
}
It's a first time I'm using Firebase and Cloud Functions, and the function worked well before I made npm update for Firebase. After update I'm getting this error and could not find a solution.