typescript - 从云函数“Closure: () => Map”调用数据时出现问题来自函数‘数据’:。”
问题描述
我正在尝试从云函数中检索数据“classCode”,但每次我得到运行时错误,即 Closure: () => Map<String, dynamic> from Function 'data':。 下面是我的代码:
Future checkDetails({
@required String classCode,
@required String email,
@required String password,
@required UserType userType,
}) async {
await sharedPreferencesHelper.clearAllData();
//Check if the School code is present and return "School not Present" if not
//Then check if the user credentials are in the database or not
//if not then return "Student Not Found" else return "Logging in"
//Api Call to check details
bool isClassPresent = false;
bool isUserAvailable = false;
String loginType = userType == UserType.STUDENT
? "Student"
: userType == UserType.TEACHER ? "Parent-Teacher" : "Parent-Teacher";
DocumentReference _classLoginRef =
classRef.collection(classCode.toUpperCase().trim()).doc('Login');
await _classLoginRef
.get().then((onValue) {
isClassPresent = onValue.exists;
print("Inside Then :" + onValue.data.toString());
});
if (!isClassPresent) {
print('Class Not Found');
return ReturnType.CLASSCODEERROR;
} else {
print('Class Found');
}
CollectionReference _userRef = _classLoginRef.collection(loginType);
注意:我使用的是 Typescript,我是 Flutter 的初学者。
解决方案
您会像下面这样更改并重试吗?
前
...
print("Inside Then :" + onValue.data.toString());
...
后
...
print("Inside Then :" + onValue.data().toString());
...
推荐阅读
- javascript - JavaScript AJAX:获取两个对象作为响应
- php - 为什么以下 SQL 查询返回空结果?
- php - 如何将我的 HTML 项目链接到 laravel?
- c - 如何从c中的3d数组中删除字符串元素
- sql-server - 将本地 SQL Server 数据库从 Visual Studio 签入 GitHub 存储库
- r - corrplot.mixed 情节在 r 笔记本中被切断
- reactjs - FullCalendar 最初是空白的 Reactjs
- flutter - Dart 中 onError 和 CatchError 的区别在哪里
- python - 'QueryDict' 对象不可调用 django pytjon
- javascript - 在我的网站的移动版本上禁用触摸键盘