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
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...
- Function in Node.JS to monitor events ar...
Hello everyone. I'm creating my first Node.JS function, but I don't have much experience with node and javascript. I'm trying to create a function, that monito...