Rank 3: Container
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 ..
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
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 ..
Admin
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
Rank 3: Container
@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 ?
Rank 7: Quantum Computer
What is the error you're getting?
Admin
Did you set an API key with enough scopes?
Rank 3: Container
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
Rank 3: Container
No error, when I check the logs it just prints any print statements I have in the code but no error or response
Rank 3: Container
The code is straight lift from documentation sample code.
Admin
Would you please share more of your updated code?
Rank 3: Container
I tried the same from client side and it works as expected just server side SDK doesn't return list of documents
Rank 3: Container
Gimme 5
Rank 3: Container
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
Admin
Do you have a catchError()?
Rank 3: Container
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
Rank 3: Container
Yup and that also has a print(error) but that doesn't trigger either when looking at logs
Admin
Did you await the result before calling res.json()?
Rank 3: Container
Future result = databases.listDocuments(
databaseId: '[DATABASE_ID]',
collectionId: '[COLLECTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
Admin
And then?
Rank 3: Container
This is exactly the code I am using, please let me know where do you want me to await
Admin
Honestly, I recommend using try/catch/await over then/catchError unless you have some specific reason not to
Rank 3: Container
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
Admin
try { final result = await databases.listDocuments(...); print(result);} catch (e) { print(e);}Rank 3: Container
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
Rank 3: Container
[Solved] ListDocuments server SDK not getting any results.
Admin
Because of the asynchronous code, your function was finishing before the API call was complete.