我想在firebase触发的用户集合中添加一个新文档.auth()但是数据库没有被填充.

这是我的firebase功能:

exports.newUser = functions.auth.user().onCreate((user) => {
    return db
        .collection("user")
        .doc(user.uid)
        .create(JSON.parse(JSON.stringify(user)));
});

这是我的注册方法:

export const register = (email, password) => dispatch => new Promise((resolve, reject) => {
    firebase.auth().createUserWithEmailAndPassword(email, password)
        .then(() => {
            resolve()
        })
        .catch(() => {
            console.log(typeof (email, password))
            reject()
        })
})

执行后,新用户将添加到身份验证中,但不会触发新文档的创建.函数newUser已成功部署到firebase.

似乎我解析用户数据的方法不正确,请建议我缺少什么?

功能日志(log):

4:38:51.935 PM outlined_flag
newUser Function execution started 4:38:52.968 PM newUser TypeError: entry.toJSON is not a function 4:38:52.968 PM newUser at /workspace/node_modules/firebase-functions/lib/common/providers/identity.js:113:70 4:38:52.968 PM newUser at Array.map () 4:38:52.968 PM newUser at Object.record.toJSON (/workspace/node_modules/firebase-functions/lib/common/providers/identity.js:113:49) 4:38:52.968 PM newUser at JSON.stringify () 4:38:52.968 PM newUser at /workspace/index.js:10:33 4:38:52.968 PM newUser at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:135:23) 4:38:52.968 PM newUser at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:144:25 4:38:52.968 PM newUser at processTicksAndRejections (node:internal/process/task_queues:96:5) 4:38:52.968 PM newUser TypeError: entry.toJSON is not a function 4:38:52.968 PM newUser at /workspace/node_modules/firebase-functions/lib/common/providers/identity.js:113:70 4:38:52.968 PM newUser at Array.map () 4:38:52.968 PM newUser at Object.record.toJSON (/workspace/node_modules/firebase-functions/lib/common/providers/identity.js:113:49) 4:38:52.968 PM newUser at JSON.stringify () more_vert 4:38:52.968 PM newUser at /workspace/index.js:10:33 4:38:52.968 PM newUser at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:135:23) 4:38:52.968 PM newUser at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:144:25 4:38:52.968 PM newUser at processTicksAndRejections (node:internal/process/task_queues:96:5) 4:38:52.979 PM outlined_flag
newUser Function execution took 1044 ms. Finished with status: error

推荐答案

firebaser here

据我所知,这个bug最近被引入了我们的函数SDK.你可以在Github回购第#1102期上查看它的状态.

Node.js相关问答推荐

node 无法验证第一个证书

如何解决TypeError:requ.isAuthenticated不是函数错误?

Firebase-admin筛选器.或只考虑第一个WHERE子句

在Android Studio中react 本机构建失败:未正确检测到Node.js版本

Mongoose查询-如何根据当前查找ID获取其他集合并将其插入到当前查找中?

try 使用Express和连接池将数据插入MySQL数据库时出现拒绝访问错误

如何使用Nextjs路由从下一步/导航在新选项卡中通过";router.ush";打开链接

几个 lambda 共有的函数

每个数组值在 mongodb 中查找一个文档

我误解了外键的工作原理吗?使用续集

将代码转换为 ES6 Discord.js 的问题

类型中缺少属性,该类型是由类实现的接口

如何使动态私有IP地址静态?

在 Express-js 中使用路由

yarn.lock 和 npm 的 package-lock 有什么区别?

适用于 Windows 7 的 NodeJS

如何在 node 调试器中禁用第一行中断

npm publish 导致'错误:EPERM:不允许操作,取消链接...',errno -4048

node 应用程序是否有任何独立的 gui 模块

在 Node 中连接和缩小 JS 文件