这里我调用的是云函数
final result =
await FirebaseFunctions.instance.httpsCallable('example').call(
{
'test1': 'test1',
'test2': 'test2,
},
);
在 CF 中我打印了所有可能的字段
@functions_framework.http
def generate_post(request) -> https_fn.Response:
# Print headers
print("Headers:")
for header, value in request.headers.items():
print(f"{header}: {value}")
# Print query parameters
print("\nQuery Parameters:")
for param, value in request.args.items():
print(f"{param}: {value}")
# Print form data
print("\nForm Data:")
for field, value in request.form.items():
print(f"{field}: {value}")
# Print JSON data
data = request.get_json(silent=True)
print("\nJSON Data:")
print(data)
# Print raw data
print("\nRaw Data:")
print(request.data.decode('utf-8'))
logging.info(f"Request data: {request.data}")
**全部都是空的**
我用postman调用它,它成功读取了参数
这是我使用的依赖项
cupertino_icons: ^1.0.6
firebase_core: ^3.1.1
firebase_auth: ^5.1.1
cloud_firestore: ^5.0.2
flutter_redux: ^0.10.0
redux: ^5.0.0
shared_preferences: ^2.2.3
cloud_functions: ^5.0.3
http: ^1.2.2
flutter --version
Flutter 3.19.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ba39319843 (5 months ago) • 2024-03-07 15:22:21 -0600
Engine • revision 2e4ba9c6fb
Tools • Dart 3.3.1 • DevTools 2.31.1
有什么想法吗?
提前致谢
除了我所做的之外,我找不到其他方式来调用 firebase CF