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
- Sudden CORS Errors - Domain hasn't Chang...
I have an Appwrite project with two web apps configured, the first one has the hostname `*` and the second one I just added to test if it could fix the issue wi...
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...
- Any way to temporarily bypass the email ...
Hey guys, any way to bypass the email verification to use the accounts again? i need to recover some projects that due to recent changes have been stopped, and ...