[英]Firebase Emulator: using PubSub in Functions
I am trying to run my Firebase functions locally through the emulator.我正在尝试通过模拟器在本地运行我的 Firebase 功能。 I have built a architecture where chains of processes are invoked by PubSub events.
我已经构建了一个体系结构,其中 PubSub 事件调用进程链。 When trying to invoke these events, the emulator logs give me this:
当试图调用这些事件时,模拟器日志给了我这个:
Sorry, we cannot connect to Cloud Services without a project ID. You may specify one with an environment variable named "GOOGLE_CLOUD_PROJECT".
I am running the emulators with --project {projectID}
.我正在使用
--project {projectID}
运行模拟器。 Also I am constructing my PubSub events like this:我也在构建我的 PubSub 事件,如下所示:
const pubsub = new PubSub({ projectId: getRealtimeDatabase().app.options.projectId })
I am using package "@google-cloud/pubsub": "^0.22.2"
, and I am importing PubSub like import { PubSub } from '@google-cloud/pubsub';
我正在使用 package
"@google-cloud/pubsub": "^0.22.2"
,并且我正在导入 PubSub,例如import { PubSub } from '@google-cloud/pubsub';
What do I have to do to make PubSub invoke new events?我必须做什么才能让 PubSub 调用新事件? Thanks!
谢谢!
Turned out getRealtimeDatabase().app.options.projectId
was undefined.原来
getRealtimeDatabase().app.options.projectId
是未定义的。 I retrieved my projectId elsewhere.我在别处检索了我的 projectId。 With the correct projectId, the code above works.
使用正确的 projectId,上面的代码可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.