I writed this method which should console.log the trigered node data, but i get error.
This is what I tried"
exports.makeUppercase = functions.database
.ref('/users/{userId}/matches')
.onWrite((snapshot, context) => {
// Grab the current value of what was written to the Realtime Database.
//const original = snapshot.val();
console.log('OnWrite works' + snapshot.after.val());
// const uppercase = original.toUpperCase();
// You must return a Promise when performing asynchronous tasks inside a Functions such as
// writing to the Firebase Realtime Database.
// Setting an "uppercase" sibling in the Realtime Database returns a Promise.
return null;
});
This is the error: makeUppercase TypeError: snapshot.val is not a function at exports.makeUppercase.functions.database.ref.onWrite (/srv/index.js:49:44) at cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at /worker/worker.js:825:24 at at process._tickDomainCallback (internal/process/next_tick.js:229:7)
Did I made something wrong?