firebase 函数模拟器 useFunctionsEmulator() 方法不起作用

BLU*_*LUE 9 firebase google-cloud-functions

我目前正在研究如何在本地测试我的云功能。我找到了几种方法,但使用 firebase 模拟器和 useFunctionsEmulator() 方法似乎很棒。在https://firebase.google.com/docs/functions/local-emulator,他们没有说明该方法,但我在这个网址上找到了如何在本地测试 `functions.https.onCall` firebase 云功能?.

但是,当我运行 firebase emulator:start 和 console.log(firebase.functions().useFunctionsEmulator(' http://localhost:5001 ') 时,它只是显示未定义。

我在原点上尝试了几个输入,但没有任何改变。互联网上关于此的信息很少,我认为这是因为这是 alpha,所以请帮助我。

小智 7

在客户端初始化 firebase 应用程序后,我通过调用 useFunctionsEmulator() 方法让模拟器工作并处理本地请求。调用它之前会导致错误。

firebase.initializeApp(config);
firebase.functions().useFunctionsEmulator("http://localhost:5001");
Run Code Online (Sandbox Code Playgroud)


app*_*pp_ 7

useFunctionsEmulator() 不返回任何东西,它只是一个二传手。

按以下方式使用它:

firebase.initializeApp(config);

const functions = firebase.functions();
functions.useFunctionsEmulator("http://localhost:5001");
Run Code Online (Sandbox Code Playgroud)