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
- Need help with createExecution function
Hi, Need some help understanding createExecution. When requesting function execution via createExecution, the function handler arguments are incorrect and rese...
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Need Help with Google OAuth2 in Expo usi...
I'm learning React Native with Expo and trying to set up Google OAuth2 with Appwrite. I couldn't find any good docs or tutorials for this and my own attempt did...