I'm struggling the get the current logged user using the method Account.get().
my code:
export async function getCurrentUser(){
try{
const currentUser = await account.get();
if(!currentUser) return null;
const user = await databases.listDocuments(
appwriteConfig.database,
appwriteConfig.usersDB,
[
Query.equal('accountId', currentUser.$id)
]
);
if(!user) throw Error("Usuario logado nao encontrado.");
return user.documents[0];
}catch(error){
console.log(error)
throw Error("Erro ao carregar o usuario logado.")
}
}
Its always returning the error:
code: 401,
type: 'general_unauthorized_scope',
response: {
message: 'User (role: guests) missing scope (account)',
code: 401,
type: 'general_unauthorized_scope',
version: '0.12.21'
}
How do I solve this?
Is this client-side code ? If yes, how have you instantiated the appwrite client ? Can you show please ?
Opps! I was running the code on server-side. Thats was the error. thanks for your help
[SOLVED] Error getting the current logged user
Recommended threads
- 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...
- > AppwriteException: The requested servi...
When trying to read or write from my database I get the following error: > AppwriteException: The requested service is disabled. You can enable the service from...