【发布时间】:2021-01-31 15:45:14
【问题描述】:
我正在使用firebase deploy --only functions 部署以下云功能:
export const testFunction = functions.https.onCall((data, context) => {
return {"data": "hello"};
});
当使用代码从客户端应用程序调用它时
var testFunction = firebase.functions().httpsCallable("testFunction");
testFunction().then((result) => {
// Read result of the Cloud Function.
this.data = result.data;
});
它按预期工作。 现在,我想继续开发在本地模拟器上测试它的功能,因此,按照文档,我将此行添加到 Web 应用程序代码中(在功能之前)
firebase.functions().useEmulator("localhost", 5001); // for local simulator
我运行本地模拟器:
firebase emulators:start --only functions
如果我现在运行客户端应用程序,我会正确地看到调用通过本地模拟器而不是远程云功能。
问题:如果修改代码,本地函数不会更新。我需要再次运行 firebase deploy 才能看到响应的变化。如何只在本地部署?
【问题讨论】:
-
根据Official Documentation,代码会在模拟器上自动更新,但如果需要转译代码,您需要再次启动模拟器。你使用的是 TypeScript 还是 React?
标签: firebase google-cloud-functions