Firebase Cloud Functions Stopped Working - Event.data Undefined
I have some cloud functionsbut they suddenly stopped working, now I'm getting event.data undefined exports.newMessageReceived = functions.database.ref('/messages/{pushId}') .onWri
Solution 1:
Cloud functions were updated to version 1.0, you can check here for more info:
https://firebase.google.com/docs/functions/beta-v1-diff#realtime-database
Regarding the question, you need to change the code into this:
exports.newMessageReceived = functions.database.ref('/messages/{pushId}').onWrite((change,context) => {
if (change.before.exists() || !change.after.exists() ) {
//Do nothing if data is edited or deletedconsole.log('Message edited or deleted - skip');
return;
}
}
onWrite
now has two parameters change
and context
. Change
has before
and after
properties, and before
is equivalent to previous
Also change
and before
can use the methods listed here:
https://firebase.google.com/docs/reference/admin/node/admin.database.DataSnapshot
Solution 2:
I had same issue.
This is a firebase documentation showing the changes that have been made on the new v1
Post a Comment for "Firebase Cloud Functions Stopped Working - Event.data Undefined"