then use account.get but wrap it in a try/catch
so for instance
const isLoggedIn = computed(() => {
const maybeLocal = localStorage.getItem("pvauser");
if (maybeLocal) {
$user.value = JSON.parse(maybeLocal);
return true;
} else if ($user.value) {
return true;
} else {
return false;
}
});
that's a basic computed to check my store value
What I would recommend is something like
const isLoggedIn = async () => {
try {
const user = await account.get();
return user (or true);
catch (e) {
return null | undefined;
}
}
For a user to register, you simply have to do account.create(ID, email, password)
Yea my getUser function is defined like this only
perfect
then when they login
you want to do account.createEmailSession
That is what creates the session
that account.get()
looks for
if that session exists, then it won't error and will return the user
Ah oke i just don't want the error to show in console, so it doesn't show to the user, but if it won't crash the app I think it's no harm
If you use try/catch
it won't error in the console
I know what you mean, I thought the same exact thing haha
but try/catch is easy and consistent
and it works for most so like
getDocument
will error if there is no document
Defined all these functions in the auth_service file so I think I am going on the right path I just need to recheck the try/catch as u said
yeah let me know if you need any more help 🙂
Sure and thanks for the help guys<:appwriteheart:782571497393750036>
Recommended threads
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Different appwrite IDs are getting expos...
File_URL_FORMAT= https://cloud.appwrite.io/v1/storage/buckets/[BUCKET_ID]/files/[FILE_ID]/preview?project=[PROJECT_ID] I'm trying to access files in my web app...
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...