flatterweb中的HTTP触发云函数

2024-04-16 10:33:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图从Flutter调用HTTP trigger Cloud Function。在将参数传递给函数时,控制台中不断出现错误Cloud Function

final HttpsCallable callable = CloudFunctions.instance.getHttpsCallable(
 functionName: 'hello_world',
);

final HttpsCallableResult result = await callable.call(
  <String, dynamic>{
    'message': 'hello world!',
  },
);

有人能指出我做错了什么吗。使用的Cloud function

def hello_world(request):
    request_json = request.get_json()
    if request.args and 'message' in request.args:
        return request.args.get('message')
    elif request_json and 'message' in request_json:
        return request_json['message']
    else:
        return f'Hello World!'

Tags: andinjsoncloudmessagehelloworldget
1条回答
网友
1楼 · 发布于 2024-04-16 10:33:21

我从您的谷歌云控制台截图中看到,您的HTTP云函数是用Python编写的

另一方面,在Dart代码中,您正在调用Callable Cloud Function

在撰写本文时,只有使用Firebase SDK for Node.js的云函数才支持可调用的云函数

如果希望用Python编写的HTTP云函数与Dart代码配合使用,则需要在云函数本身中实现protocol for ^{}

您将发现一个示例here(未测试)


根据您的上述评论进行更新:从您的云函数代码中,我们可以确认您没有实现https.onCall的协议

相关问题 更多 >