// ============================== GET ACCOUNT export async function getAccount() { try { const currentAccount = await account.get(); console.log(currentAccount);
return currentAccount;
} catch (error) { console.log(error); // error here } }
// ============================== GET USER export async function getCurrentUser() { try { const currentAccount = await getAccount();
if (!currentAccount) throw Error;
const currentUser = await databases.listDocuments(
config.databaseId!,
config.userCollectionId!,
[Query.equal("userId", currentAccount.$id)]
);
if (!currentUser) throw Error;
return currentUser.documents[0];
} catch (error) { console.log(error); return null; } }
Recommended threads
- Collections list not showing up when try...
I'm trying to create new relationship attribute but both one way and two way relationship is not showing up collections list to connect with my relationship att...
- I have try to use the appwrite in to the...
Invalid Origin. Register your new client (oailedjdbkhlkakmnnapoonllbnfmfij) as a new Web (Chrome Extension) platform on your project console dashboard
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...