【问题标题】:Callable Cloud Function error: Response is missing data field, when trying to call cloud function written in python from flutter app可调用云函数错误:响应缺少数据字段,当尝试从颤振应用程序调用用 python 编写的云函数时
【发布时间】:2021-08-29 09:28:13
【问题描述】:

几天来,我一直在尝试调用一个用 Python 编写的云函数,该函数不从我的颤振应用程序中获取任何参数,但我不断收到一条错误消息,提示“响应缺少数据字段”。这让我很困惑,因为该函数没有参数,所以我想知道我是否遗漏了什么。

这就是python函数的样子:

def create_algorand_account(request):
request_json = request.get_json(silent=True)

returned_dict = {'user_address':address,'user_passphrase':mnemonic}
return returned_dict

这是调用的样子:

Future<void> createHotWallet() async {
String id = getRandomString(30);
final HttpsCallable callable = FirebaseFunctions.instance.httpsCallable(
  'createAlgorandAccount',
);

try {
  final HttpsCallableResult result = await callable.call();
  final hotWallet = HotWallet(
    id: id,
    address: result.data['user_address'],
    passphrase: result.data['user_passphrase'],
    webblenAmount: 0,
    algoAmount: 0,
  );
  await hotWalletsRef.doc(id).set(hotWallet.toMap()).catchError((e) {
    return e.message;
  });
} on FirebaseFunctionsException catch (e) {
  print(e);
} catch (e) {
  print(e);
}

}

【问题讨论】:

    标签: python firebase flutter google-cloud-functions


    【解决方案1】:

    Callable Cloud Functions 目前只能在 Node.js 中实现。您在 Python 代码中拥有的是一个常规的 HTTP 云函数,您应该使用来自您的代码的常规 HTTP 请求来调用它。

    【讨论】:

      猜你喜欢
      • 2020-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-18
      • 2021-04-08
      • 1970-01-01
      • 2021-09-25
      相关资源
      最近更新 更多