you need to createsession, check the auth docs
Hey @Ayush yes you need to create a session and then only you will be able to get the details of the logged in account.
also account.get returns a promise. You will also need to handle that
https://appwrite.io/docs/references/cloud/client-web/account#get%20account
Ayush is using await inside an async function
Is there anything wrong about it?
Use :
account.get();
@Ayush the error seems to be because there's not any active session
Are you sure you have logged in previously?
Yess guys I think it's fixed now
Thank you everyone for your help
What was the solution?
As everyone said, I was trying get the current user without creating any session
It was under a useEffect thus it was throwing the error as soon as I reload the page
Basically the problem was with my code and not with appwrite configuration
No, I was pointing out why you donβt need to deal with the Promise
Okay okay got it
Great!
[fixed] Error 401 (unauthorized) on using get Account
[SOLVED] Error 401 (unauthorized) on using get Account
@Ayush Hello bro dm me i want to ask some questions.
@Ayush I am also getting same problem, I also fetching current user data in useEffect hook, without login also its trying to fetch data. please help me to resolve this issue
Hi Murali! I tried fixing it and talking with the appwrite team but couldn't get any useful, So I used supabase instead for the auth functionality
@Ayush in my case, before logging in, the useEffect hook fetching getCurrentUser, initially there is no session. Don't know how to avoid this
please create a new <#1072905050399191082> post instead of posting in an old thread
Recommended threads
- is `account.get()` safe to be used in th...
I want to user's `id` for authentication. However, a while ago I was told in this server not to use `account.get()` and instead add user preferences for that us...
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...
- CORS errors in Obsidian custom plugin
Hi, anyone here familiar with obsidian community plugins? In short: it's a local first note app which supports writing your own add-ons / plugin But I keep get...