skip to Main Content

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!

2

Answers


  1. 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

    Login or Signup to reply.
  2. As it stands Cloud is not on 1.5.x so you will have to use 13.0.2 version to get the cloud and your app working.

    • They made some major change on how Appwrite handles query so Don’t use 14.0.0 on Cloud as its not using 1.5.x.
    • Appwrite cloud is transitioning to 14.0.0 but I guess it would take time.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search