Web Developer
hello, I have got this error when using 'account. get();' this method. I have provided the error msg and code can you help me with any more information you need I will provide it.
CODE
Auth.js
import conf from "../conf/conf.js";import { Client, Account, ID } from "appwrite";
export class AuthService { client = new Client(); account;
constructor() { this.client .setEndpoint(conf.appwriteUrl) .setProject(conf.appwriteProjectId); this.account = new Account(this.client); }
async createAccount({ email, password, name }) { // eslint-disable-next-line no-useless-catch try { const userAccount = await this.account.create( ID.unique(), email, password, name ); if (userAccount) { // call another mwthod return this.login({ email, password }); } else { // throw new Error("Failed to create user account"); return userAccount; } } catch (error) { throw error; } }
async login({ email, password }) { // eslint-disable-next-line no-useless-catch try { return await this.account.createSession(email, password); } catch (error) { throw error; } }
async getCurrentUser() { // eslint-disable-next-line no-useless-catch try { return await this.account.get(); } catch (error) { console.log("Appwrite serive :: getCurrentUser :: error", error); return null; }
}
async logout(){
// eslint-disable-next-line no-useless-catch try { await this.account.deleteSessions(); } catch (error) { throw error; } }}
const authService = new AuthService();
export default authService;
/```