【发布时间】:2021-07-05 01:56:25
【问题描述】:
我正在尝试从另一个云函数调用云函数“startTimer”,并在调用函数“startTimer”时包含数据
例如,在我的客户端,很容易调用函数“startTimer”并通过编写以下代码来包含数据(颤振代码):
HttpsCallable callable = FirebaseFunctions.instance.httpsCallable('startTimer');
callable.call({"gameId": MyFirebase.gameId});
然后我可以通过执行以下操作在我的云函数“startTimer”中检索数据:
exports.startTimer = functions.https.onCall(async (data, context) => {
const gameId = data.gameId;
如何在另一个云函数中调用函数“startTimer”并包含数据 (gameId)?此外,我将如何做到这一点,以便数据的格式/结构与上面的代码 sn-p (data.gameId) 一样? 我尝试了类似的方法,但它不起作用:
fetch("https://{LOCATION}-{PROJECT-ID}.cloudfunctions.net/startTimer", {
method: "POST",
body: JSON.stringify({"gameId": gameId}),)};
“取”来自
const fetch = require("node-fetch");
我对 javascript/typescript 很陌生,因此非常感谢任何帮助/参考 :) 提前谢谢!
【问题讨论】:
标签: node.js firebase google-cloud-functions