#I'm developing a CLI application using Node.js
6 messages · Page 1 of 1 (latest)
@signal vine hope that helps
can you try encapsulating all the 3 calls in one async function and await them all?
i believe account isnt created because its not awaited and the login function is returning an error
import { Client, Account, ID } from 'node-appwrite';
const client = new Client()
.setProject('runner')
const account = new Account(client);
async function createAccount() {
const data = await account.create(ID.unique(), '[email protected]', '123456789', 'John Doe');
console.log('Account created:', data);
}
async function getAccount() {
const data = await account.get();
console.log('Account:', data);
}
async function login() {
const data = await account.createEmailPasswordSession('[email protected]', '123456789');
console.log('Session created:', data);
}
async function main(){
await createAccount();
await login();
await getAccount();
}
main();
are you running this script via node index.js?
how are you running it