Firebase Cloud Functions TypeError: Cannot read property 'val' of undefined
I have started using fire-base functions some time back and it was in beta release.
When I try to update the functions within the production with the different node packages of firebase functions, following error occurred.
I have used number of fire base functions and all of them triggering based onWrite leads to the above error.
After small search I found the following discussion ,
https://stackoverflow.com/questions/49746905/firebase-typeerror-cannot-read-property-val-of-undefined?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
I have moved from "firebase-functions": "^0.9.1", to "firebase-functions": "^1.0.2", where there is a major change in method definition as indicated below.
When I try to update the functions within the production with the different node packages of firebase functions, following error occurred.
I have used number of fire base functions and all of them triggering based onWrite leads to the above error.
After small search I found the following discussion ,
https://stackoverflow.com/questions/49746905/firebase-typeerror-cannot-read-property-val-of-undefined?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
I have moved from "firebase-functions": "^0.9.1", to "firebase-functions": "^1.0.2", where there is a major change in method definition as indicated below.
Change this:
exports.pushNotification = functions.database.ref('/messages').onWrite( event => {
const message = event.data.val();
const user = event.data.val();
});
to this:
exports.pushNotification = functions.database.ref('/messages').onWrite(( change,context) => {
const message = change.after.val();
});
Comments
Post a Comment