Error
User getCurrentuser : AppwriteException: User (role: guests) missing scope (account)
at Client.
My code:
import { Client,Account,ID } from "appwrite";
export class AuthService{
client=new Client();
account;
constructor(){
this.client
.setEndpoint(conf.appwriteURL)
.setProject(conf.appwrite_projectID);
this.account = new Account(this.client);
}
async getCurrentUser()
{
try{
return await this.account.get();
}
catch(e)
{ console.log("USer getCurrentuser :",e);
}
return null;
}
}
I am using appwrite for a backend for my React app. How can I resolve this issue, and how can I add role in appwrite?
that just means you're not logged in yet :)
This approach is correct, you check to see if you're logged in, if not, redirect to login page in the catch.
You can create a session in a variety of ways, email pass, anonymous, phone auth, etc.
https://appwrite.io/docs/products/auth/quick-start