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
- MongoDb Database Breaks integer[] & bigi...
I've got a table with the below column created. When I try to insert the value `[-3408048000]` into it, the dart sdk cloud function call is successful (no error...
- Missing Invoice
Hi! I need help with billing on my account (marelu@gmail.com). I have never received a single invoice by email. My organization has been on the Pro plan since...
- Appwrite Functions cold start
Hello. I'm seeing really long cold starts on Appwrite Cloud Functions and wanted to know if this is expected. My function just authenticates the user, fetches ...