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
- Hi Folks, Database Writing Issue
Hey Folks im trying to get logging setup on my website but im getting an error, i dont have any document id and i think this is the issue but i havent got the f...
- script "build" was terminated by signal ...
Heyo, For some reason, my Next.js 16.0.10 version does not build properly. Here is the last logs: ``` 1063 packages installed [22.54s] $ next build ⚠ No build...
- Error with realtime channels
I'm performing a subscription to realtime channels, and after a few seconds I get an exception with this error: {\"type\":\"error\",\"data\":{\"code\":1008,\"me...