
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
- Subject: Request for temporary quota lif...
Hi Appwrite Team, our nonprofit animal rescue app on Appwrite Cloud is currently throttled due to read‑quota limits, and we need a temporary increase so rescue ...
- Console create row ui not passing ID.uni...
I'm getting an error saying the id is already used but it should be created with ID.unique() it doesn't seem to be reading the row ID field at all. I can't get ...
- [FEATURE] Better usage analytics for app...
Recently, i've gotten **73** emails from appwrite regarding excesive GBHours usage. I've almost hit the limit of 1000 and it is really hard to track down which ...
