
I'm attempting to retrieve data from a database collection which contains two attributes. A userid/documentid and a list of Type string [] topics. However, I currently get this error in the console. I am attempting to retrieve these and present them on my front-end. Is there something wrong with the way that I am retrieving these documents? I have stored the topics as a list of strings.
error:
main.dart.js:28183 User document data: {firstName: Jim, lastName: Halpert, userid: 65b73a56b64d1d9b0fd5, email: jim@gmail.com, $id: 65b73a56b64d1d9b0fd5, $createdAt: 2024-01-29T05:40:39.328+00:00, $updatedAt: 2024-01-29T05:40:39.328+00:00, $permissions: [], $databaseId: 65a6487dde332646854c, $collectionId: 65a64900d60baca39d1b}
main.dart.js:28183 Error fetching user preferences: NoSuchMethodError: method not found: 'gaf' on null
appwrite function:
// getUserPreferences function
Future<List<String>> getUserTopics(String userId) async {
try {
final userPreferencesDatabase = Databases(client);
final preferencesDocument = await userPreferencesDatabase.getDocument(
databaseId: '6581a7a98574997f7e84',
collectionId: '6581a97c17588b1fb066',
documentId: userId,
);
return List<String>.from(preferencesDocument.data['Topics']);
} catch (e) {
// Handle error
print("Error fetching user preferences: $e");
return [];
}
}
appwrite function:
Future<void> _updateUserTopics() async {
String? userId = await getUserId();
if (userId != null) {
List<String> topics = await getUserTopics(userId);
setState(() {
_topicsController.text = topics.join(', ');
});
} else {
print("User ID is null");
}
}
Recommended threads
- how many Teams can be created?
I am creating an app where I will let users create groups. This could mean there will be many groups created by user, to isolate those groups properly I am thin...
- Cannot create a user
Hi, I am using a lowcoder frontend and trying to create a user in Appwrite (python function). Unfortunately, all I got is an error: "Raw body: Error". It means...
- React native app login via Safari
Hi! I deployed for debug my React Native app in web, chrome everythink works well but in safari on mac and ios I cant login. I found this one error in safari co...
