Error in Cloud Functions database Cannot read property 'val' of undefined
See original GitHub issueFirebase SDK for Cloud Functions Migration Guide: Beta to version 1.0
In the code provided we need to remove the variable (event) and replace it with (change,context): this is the snippet of my working code:
exports.emojify =
functions.database.ref('/messages/{pushId}/text')
.onWrite((change,context) => {
console.log("emojifying!");
// Get the value from the 'text' key of the message
const originalText = change.after.val();
const emojifiedText = emojifyText(originalText);
// Return a JavaScript Promise to update the database node
return change.after.ref.set(emojifiedText);
});
Reference from this StackOverflow post: 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
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:8
Top Results From Across the Web
Cloud Function error "Cannot read property 'data' of undefined"
I recently started playing with cloud functions and I am getting this error: > TypeError: Cannot read property 'data' of undefined > at ......
Read more >Troubleshooting Cloud Functions - Google Cloud
Cloud Functions deployment can fail if the entry point to your code, that is, the exported function name, is not specified correctly. The...
Read more >Cloud Function returned "Cannot read property 'attributes' of ...
This error usually occurs when you try to read an attribute of array, not of object(which u probably wanted). Recheck the value types....
Read more >Call functions from your app | Cloud Functions for Firebase
Sending back the result; Handle errors; Deploy the callable function ... the default us-central1 , you must set the appropriate value at initialization....
Read more >Cannot read properties of undefined (reading 'firestore')" mean?
I have a cloud function that is being executed successfully but it only returns a null value as a response to my app....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
work for me:
@jerrychong25 I used this code, and it finally works: https://discussions.udacity.com/t/firebase-lesson-3-deploy-and-test-error/656031/3