【发布时间】:2018-07-07 12:52:37
【问题描述】:
我正在使用 Firebase 函数。我通过命令设置了一个环境变量:
firebase functions:config:set my.token="abcde"
我通过命令验证了:
firebase functions:config:get
返回我:
{
"my": {
"token": "abcde"
}
}
在我的 index.js 中,我尝试通过以下方式获取设置的令牌:
const tok = functions.config().my.token
我想通过this document 在本地测试我的功能,所以我运行命令:
firebase serve --only functions
但它给了我错误:
Error from emulator. FirebaseError: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'token' of undefined
为什么我无法访问我在 Firebase 环境变量中设置的令牌?
【问题讨论】:
标签: firebase google-cloud-functions firebase-cli