gpt4 book ai didi

firebase - 如何在本地测试 `functions.https.onCall` firebase云功能?

转载 作者:行者123 更新时间:2023-12-02 16:07:23 24 4
gpt4 key购买 nike

我似乎无法在 Firebase Documentation 中找到此问题的解决方案.

我想在本地测试我的 functions.https.onCall 函数。是否可以使用 shell 或以某种方式将我的客户端(启用了 firebase SDK)连接到本地服务器?

我希望避免每次都为了测试 onCall 函数的更改而进行部署。

<小时/>

我的代码

功能:

exports.myFunction = functions.https.onCall((data, context) => {
// Do something
});

客户:

const message = { message: 'Hello.' };

firebase.functions().httpsCallable('myFunction')(message)
.then(result => {
// Do something //
})
.catch(error => {
// Error handler //
});

最佳答案

对于本地,您必须调用(在 firebase.initializeApp 之后)

firebase.functions().useFunctionsEmulator('http://localhost:5000') 

关于firebase - 如何在本地测试 `functions.https.onCall` firebase云功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50884534/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com