
Indeed unresolved still and now I am struggling with another weird one where my function deployment build keeps failing ... Restarted all containers but issue still persists so havnt been able to do any new code tests ..

usually, the problem is either syntax error or an exception thrown in the code. If you want help, feel free to create another post with details on your error and your code

@Steven @Binyamin figured out the function deployment but the query still doesn't return any results, removed the query and just straight listDocuments doesn't do anything either.. Any ideas where I could look to troubleshoot ?

What is the error you're getting?

Did you set an API key with enough scopes?

Yes, since this is still in dev, I have 1 key with full scope.. I am able to write to the DB just the list documents query doesn't do anything

No error, when I check the logs it just prints any print statements I have in the code but no error or response

The code is straight lift from documentation sample code.

Would you please share more of your updated code?

I tried the same from client side and it works as expected just server side SDK doesn't return list of documents

Gimme 5

Well the code attached in the post is pretty much it, I have removed the "queries:" altogether but still the "result.then" block never triggers .. I assume API key based access is not restricted by collection or document level restrictions

Do you have a catchError()?

So Key is not the issue and since its API key based request, I assume, collection and document based security is overridden and I should get results

Yup and that also has a print(error) but that doesn't trigger either when looking at logs

Did you await
the result before calling res.json()
?

Future result = databases.listDocuments( databaseId: '[DATABASE_ID]', collectionId: '[COLLECTION_ID]', );
result .then((response) { print(response); }).catchError((error) { print(error.response); });

And then?

This is exactly the code I am using, please let me know where do you want me to await

Honestly, I recommend using try/catch/await over then/catchError unless you have some specific reason not to

Can you spoon feed me a 3 line sample code of how you want me to try doing it just so I know I am doing it right

try {
final result = await databases.listDocuments(...);
print(result);
} catch (e) {
print(e);
}

Hey @Steven thanks for the help, it does work now. Not sure what was broken before since my original code was straight lift from appwrite documentation. But thanks to you its working now. Cheers

[Solved] ListDocuments server SDK not getting any results.

Because of the asynchronous code, your function was finishing before the API call was complete.
Recommended threads
- custom requirements.txt file
How do I specify a custom requirements.txt file when creating a serverless function through the Appwrite console?
- Is my approach for deleting registered u...
A few weeks ago, I was advised not to use the registered users' id in my web app. Instead, I store the publicly viewable information such as username and email ...
- ❗[Help] Function stuck in "waiting" stat...
Hi Appwrite team 👋 I'm trying to contribute to Appwrite and followed the official setup instructions from the CONTRIBUTING.md guide to run the platform locall...
