我编写了一个简单的云函数,它返回一个保存在我的 Cloud Firestore 数据库中的 ID。
云函数如下所示:
exports.getWinkert = functions.https.onCall((data, context) => {
return admin.firestore().collection('users').doc('hash').get()
.then(snapshot => {
const winkertId = snapshot.wwinkert
return { id: winkertId };
})
})
此函数是使用以下代码从我的 flutter 应用中调用的:
Future _getValues() async {
final HttpsCallable callable = CloudFunctions.instance.getHttpsCallable(
functionName: "getWinkert",
);
dynamic resp = await callable.call(<String, dynamic>{
"name": "wwinkert",
});
print(resp.toString());
}
调用该函数后,我得到了这个结果:
I/flutter ( 8253): Instance of 'HttpsCallableResult'
问题:如何从 Dart 中的 HttpsCallableResult 实例获取数据?
提前感谢您的帮助!
您好, 劳尔
最佳答案
快速浏览此文档:
https://github.com/flutter/plugins/tree/master/packages/cloud_functions
表明可以通过将 .data 添加到 HttpsCallableResult 对象来获取数据。
. . .
我很抱歉:D
关于firebase - Flutter + Firebase Cloud Functions - 如何从 HttpsCallableResult 获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56400220/