如何在本地测试`functions.https.onCall` firebase云功能? [英] How to test `functions.https.onCall` firebase cloud functions locally?
本文介绍了如何在本地测试`functions.https.onCall` firebase云功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Firebase文档中,我似乎找不到解决方案.
I can't seem to find the solution for this in the Firebase Documentation.
我想在本地测试我的functions.https.onCall
函数.是否可以使用Shell或以某种方式将我的客户端(已启用Firebase SDK)连接到本地服务器?
I want to test my functions.https.onCall
functions locally. Is it possible using the shell or somehow connect my client (firebase SDK enabled) to the local server?
我想避免每次都只是为了测试对我的onCall
功能所做的更改而部署.
I want to avoid having to deploy every time just to test a change to my onCall
functions.
功能:
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之后)
For locally you must call (after firebase.initializeApp)
firebase.functions().useFunctionsEmulator('http://localhost:5000')
这篇关于如何在本地测试`functions.https.onCall` firebase云功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文