【发布时间】:2020-07-01 23:07:05
【问题描述】:
我写了这个方法,它应该控制台记录触发的节点数据,但我得到了错误。
这是我试过的”
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;
});
这是错误: make大写 TypeError:snapshot.val 不是位于 cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions) 的 export.makeUppercase.functions.database.ref.onWrite (/srv/index.js:49:44) 的函数.js:131:23) at /worker/worker.js:825:24 at at process._tickDomainCallback (internal/process/next_tick.js:229:7)
我是不是做错了什么?
【问题讨论】:
标签: javascript firebase firebase-realtime-database google-cloud-functions