尝试部署一个为数据库触发 OnCreate 的函数,但它一直向我返回此错误。这是简单的代码和错误响应:
只是无法弄清楚为什么匹配未定义错误?
模块版本:
nodejs: Version 8.11.3
Function : deployed with node 8 runtime version.
"firebase": "^5.3.0"
"firebase-admin": "^5.12.1"
"firebase-functions": "^1.1.0"
"typescript": "^2.5.3"
Code:
import functions = require('firebase-functions');
import admin = require('firebase-admin');
exports.functionName = functions.database.ref('/user/{uid}/email').onCreate((snap, context) => {
console.log(snap.val());
});
问题更新:这是最新且最新的代码。我正在尝试获取新添加的对象的详细信息。
错误:Firebase 数据库中向用户添加了新元素:
TypeError: Cannot read property 'match' of undefined
at resourceToInstanceAndPath (/srv/node_modules/firebase-functions/lib/providers/database.js:154:26)
at dataConstructor (/srv/node_modules/firebase-functions/lib/providers/database.js:122:38)
at Object.<anonymous> (/srv/node_modules/firebase-functions/lib/cloud-functions.js:89:32)
at Generator.next (<anonymous>)
at /srv/node_modules/firebase-functions/lib/cloud-functions.js:28:71
at new Promise (<anonymous>)
at __awaiter (/srv/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
at cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions.js:82:36)
at /worker/worker.js:728:24
at <anonymous>
您正在使用 Cloud Functions 的“旧”语法(Firebase SDK for Cloud Functions 版本 1.0.0 之前的版本)onCreate((event) => {})
并且您项目中的SDK版本为1.1.0版本。
您应该将语法更改为
.onCreate((snap, context) => {})
如中所解释的文档
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)