Dear community, as I understood the best way to check for an active session is account.get() and if it returns an 401 there is no active session. Now I would prefer to handle that error more gracefully and not show an error in the console. I figured my api call would look like this
try {
const currentUser = await account.get();
console.log("API Call Current User", currentUser);
return currentUser;
} catch (error: any) {
if (error.code === 401) {
// Handle 401 Unauthorized error specifically
console.log("Unauthorized, no User Logged In")
return undefined;
}
console.error("Error fetching current user:", error);
return undefined; // Return undefined if the API call fails
}
};
However, even before the catch I get an error thrown in the console.
GET https://domain/v1/account 401 (Unauthorized)```
Is this an error thrown from the Appwrite SDK? Anyone an idea on how to handle the 401 more gracefully and avoid this "unnecessary" 401 error in the console?
Recommended threads
- The console isnt showing documents
In console ui saved documents are being shown on frontend but i can see its showing 4 or number of docs available but in rows its only showing single doc and th...
- Create a project via REST API or SDK, mi...
I am currently self-hosting Appwrite in my local machine, deployed using docker script in the website. I also installed `appwrite-cli` through npm. I am trying...
- 1.8.1 - Databases - inline updating a ro...
When updating a database field via the inline edit method, the `$updatedAt` column does not get updated. Only if the row is updated by the "Update" interface (t...