Back

Need to get the document list data from listDocuments

  • 0
  • Databases
  • Flutter
Vanshaj Kataria
19 Apr, 2024, 15:35

Need Help! I am writing the code below

TypeScript
Client client = FFAppState().appwriteClient;
Databases dbInstance = Databases(client);
DocumentList homesList = await dbInstance.listDocuments(
  databaseId: FFAppConstants.dbInstance,
  collectionId: FFAppConstants.homesCollection,
);
print('homesList => ${homesList.documents}');
return homesList.documents;

I am just getting the Instance not data, when I print it.

TL;DR
Developers are having trouble getting document list data using `listDocuments` method. The code just returns the instance not the data when printed. Solution: Make sure to use the `data` property of the `DocumentList` object to access the actual documents. Update the code like this: ``` Client client = FFAppState().appwriteClient; Databases dbInstance = Databases(client); DocumentList homesList = await dbInstance.listDocuments( databaseId: FFAppConstants.dbInstance, collectionId: FFAppConstants.homesCollection, ); print('homesList => ${homesList.data}'); // Use data
Vanshaj Kataria
19 Apr, 2024, 15:59

@darShan need help

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more