【发布时间】:2020-08-07 11:52:14
【问题描述】:
我有一个 Firebase 云(可调用)函数,它可以删除一个 Firestore 文档和所有子实体,包括子集合。我通过稍微修改在他们的文档中提供我的 firebase 的函数来做到这一点:https://firebase.google.com/docs/firestore/solutions/delete-collections
重要的一点在这里:
...
return firebase_tools.firestore
.delete(path, {
project: process.env.GCLOUD_PROJECT,
recursive: true,
yes: true,
token: functions.config().fb.token
})
...
当我从我的网页调用此函数时(在用户进行身份验证后),Web 客户端会抛出远程函数导致错误的错误。在 firebase 控制台中,我发现此错误:
Unhandled error TypeError: Cannot read property 'token' of undefined
这是指向上面代码sn-p中的行:token: functions.config().fb.token。所以.fb 为空。
这是怎么回事?
在网上搜索告诉我一些关于login:ci 在命令行中的信息,但是虽然我是在我的笔记本电脑上开发它,但当应用程序部署时,将没有命令行。该网站将在 firebase 托管。它调用了一个 firebase 云函数。我正在使用 firebase auth 进行用户身份验证(电子邮件/密码)并将数据存储在 firestore 中。
此外,我已经在命令行上启用了,因为我可以执行 firebase deploy --only functions 就好了。如何确保functions.config().fb 不返回空值??
【问题讨论】:
标签: firebase google-cloud-firestore firebase-authentication google-cloud-functions