
The code snippet is:
TypeScript
export async function getCurrentUser() {
try {
const currentAccount = await account.get();
if(!currentAccount) throw Error;
const currentUser = await databases.listDocuments(
appwriteConfig.databaseId,
appwriteConfig.userCollectionId,
[Query.equal('accountId', currentAccount.$id)]
);
if(!currentUser) throw Error;
return currentUser.documents[0];
} catch (error) {
console.log(error);
}
}
If I remove Query, it is not showing error. With Query, it gives error.
Need Help!!
TL;DR
Issue: Error encountered while using Query.equal() in the getCurrentUser function.
Solution: Update the code snippet as follows:
```javascript
import { Query } from 'appwrite';
export async function getCurrentUser() {
try {
const currentAccount = await account.get();
if (!currentAccount) throw Error;
const currentUser = await databases.listDocuments(
appwriteConfig.databaseId,
appwriteConfig.userCollectionId,
[new Query().equal('accountId', currentAccount.$id)]
);
if (!currentUser) throw Error;
return currentUser.documents[0];
} catch (error) {
consoleRecommended threads
- Getting Error On self host SSL update
Hi, I am using app write for my app backend version i am using is 1.6.2 yesterday my ssl is expired and now i am not able to renew it because of it my app is no...
- Function Cannot be deleted
I think this shouldn't happen!
- CORS Issue | DID NOT FIND ANYTHING ON DO...
Hello There, I get the Error ```Access to fetch at 'https://fra.cloud.appwrite.io/v1/account' from origin 'http://localhost:5173' has been blocked by CORS poli...
