while implementing login signup functionality using appwrite I am getting invalid URL error in appwrite. I am also attaching the ss of it below for reference. It will be of great help if someone can help me debug this
can u post the code here in text?
yes sure
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}){ try{ const userAccount=await this.account.create(ID.unique(),email,password,name) if(userAccount){ return this.loginAccount({email,password}) } else{ return userAccount } } catch(error){ throw error } } async loginAccount({email,password}){ try{ return await this.account.createEmailPasswordSession(email,password); } catch(error){ throw error } } async getCurrentUser(){ try{ return await this.account.get() } catch(error){ console.log("Appwrite servce :: getCurrentUser():: ",error) } return null } async logout(){ try{ return await this.account.deleteSessions(); } catch(error){ console.log("Appwrite servce :: logout():: ",error) } }
};
// import { Client, Account, ID } from "appwrite";
// const client = new Client() // .setEndpoint('https://cloud.appwrite.io/v1') // .setProject('<PROJECT_ID>');
// const account = new Account(client);
const AuthServiceObj=new AuthService() export default AuthServiceObj;
this is the code of the Auth file
@chiranjeev pls use three backticks to format and post
ok sir
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}){
try{
const userAccount=await this.account.create(ID.unique(),email,password,name)
if(userAccount){
return this.loginAccount({email,password})
}
else{
return userAccount
}
}
catch(error){
throw error
}
}
async loginAccount({email,password}){
try{
return await this.account.createEmailPasswordSession(email,password);
}
catch(error){
throw error
}
}
async getCurrentUser(){
try{
return await this.account.get()
}
catch(error){
console.log("Appwrite servce :: getCurrentUser():: ",error)
}
return null
}
async logout(){
try{
return await this.account.deleteSessions();
}
catch(error){
console.log("Appwrite servce :: logout():: ",error)
}
}
};
// import { Client, Account, ID } from "appwrite";
// const client = new Client()
// .setEndpoint('https://cloud.appwrite.io/v1')
// .setProject('<PROJECT_ID>');
// const account = new Account(client);
const AuthServiceObj=new AuthService()
export default AuthServiceObj;
Recommended threads
- Locked out from my own account
I've create an appwrite account using onedevcontext@gmail.com and tried upgrading to Pro multiple times but failed as the Credit Card would not be accepted, I t...
- Not able to upgrade to Appwrite Pro
This is my project ID - 69f5bee60036512d2d52 I've tried multiple credit cards now and I still face the same error "Your card was declined". But I've used the s...
- Running into a server error on my self-h...
Hey everyone, I'm running into a server error on my self-hosted setup after updating to v1.19.0. The issue only happens during user creation and deletion. Ever...