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
- [ENHANCEMENT] Use the custom Next.js dep...
Deployment adapters on Next.js are now stable! This means that we don't have to stick to the limitations of sniffing out build outputs and manually moving or mo...
- NextJS builds sudden runtime_timeout
My builds suddenly stopped working. Activating old prebuilt snapshots work, but redeploying that same code produces builds that throw runtime_timeout FRA region
- Project paused?
Hello, I have two Appwrite projects and I can not resume them for some reason. I'm using the free plan, and I saw in the pricing page that 2 free projects are a...