#[SOLVED] Unauthenticated and not successful but sends data to appwrite database

22 messages · Page 1 of 1 (latest)

turbid condor
#

I be getting this error on my console.
GET https://cloud.appwrite.io/v1/account 401 (Unauthorized)
When I fill my form and click my submit button a Post request is created but it also encounters a similar error.

civic spruce
turbid condor
#

I looked at the documentation and changed a lil thing to and now I am getting this instead upon filling the form and submiting along with the error u said is normal.

GET https://cloud.appwrite.io/v1/databases/65d71e706ceb976dee31/collections/65d723193862862e5c9a/documents?queries[0]={"method"%3A"equal"%2C"attribute"%3A"accountId"%2C"values"%3A["65e35a3b53748ca9bc5e"]} 500 (Internal Server Error)

// ============================== GET USER
export async function getCurrentUser() {
try {
const currentAccount = await getAccount();

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);
return null;
}
}

#

My request looks somthing like the above.

#

Below is my onSubmit command.

// 2. Define a submit handler.
async function onSubmit(values: z.infer<typeof SignupValidation>) {

console.log(values)

const newUser = await createUserAccount(values);

// console.log(newUser)

if (!newUser) {
  return toast({
    title: "Signed up failed. Please try again. No new user.",
  });
}

console.log(values.email, values.password)

const session = await signInAccount({
  email: values.email,
  password: values.password,
});

if (!session) {
  return toast({ title: "Sign in failed. Please try again. No session" });
}

const isLoggedIn = await checkAuthUser();

if (isLoggedIn) {
  form.reset();

  navigate("/");
} else {
  return toast({ title: "sign up failed. Please try again. No loggin" });
}

}

civic spruce
turbid condor
#

I am sorry what is that and how do I confirm that?

civic spruce
turbid condor
#

I dont think I am.

civic spruce
turbid condor
#

{
"name": "snapgram",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
"@tanstack/react-query": "^5.22.2",
"appwrite": "^14.0.0-rc.5",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.335.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.50.1",
"react-router-dom": "^6.22.1",
"tailwind-merge": "^2.2.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^20.11.19",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.17",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.2.2",
"vite": "^5.1.4"
}
}

civic spruce
turbid condor
#

Yeah so what can I do to rectify?

ripe gust
#

You should try the stable version atm i.e. - "appwrite": "13.0.2".

#

And hit npm install.

turbid condor
#

So I could run at latest right?

#

Will this completely rectify the issue?

vernal niche
# turbid condor Will this completely rectify the issue?

You don't need the RC, as the release candidate has some breaking features that only work using appwrite console 1.5

The cloud version does not have this version yet. I recommend reverting back to 13.0.2, which is the latest version. The 14.x.x are still WIP and release candidates, which do break these kind of things usually. Try it!

turbid condor
#

Ok thank You guys. I think it’s resolved.

vernal niche