AppwriteException: Invalid query:

104 views Asked by At

Here I am trying to run this query and it is giving me error. I don't understand why it is a bad request. I am trying to get the specific user from the database using accountId. Please help

This is the function to call the get current user

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])]
    );
    console.log(currentUser);

    if (!currentUser) throw Error;
    return currentUser.documents[0];
  } catch (error) {
    console.log("from getCurrentUser");
    console.log(error);
  }
}

**this specific line is not executing **

[Query.equal("accountId", [currentAccount.$id])]

**this is the error ** Error message

this is the response request response with the query

note that without [Query.equal("accountId", [currentAccount.$id])] this line the request is working fine. giving me response of

without the query

please help!

1

There are 1 answers

0
Dipto Sarkar On

Maybe you are using appwrite: 14.0.0 | Just downgrade this to 13.0.2 | Go to your package.JSON and replace this ("appwrite": "^14.0.0") with ("appwrite": "^13.0.2") and install the dependencies again (npm i).

Everything will solved.

appwrite in package.jason