Rank 2: Process
I have a function that checks for authentication in the following way
- Initialize the client using
jwtpassed by the user
const client = new Client() .setEndpoint(process.env.APPWRITE_API_ENDPOINT) .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) .setJWT(req.headers['x-appwrite-user-jwt'])- Authenticate function to check if a user is a valid one
import { Account } from "node-appwrite"
export async function authenticate(client, log, error) { log("Initializing Account") const account = new Account(client) let user = null try { log("Getting account") user = await account.get() log(user) if (!user.email) throw Error("User does not have email") log(user.$id, 'authenticated') } catch (e) { user = null error(e.toString()) } return user}However I get the following logs,
Initializing Account
Getting account
And the following error logs,
Error: connect ECONNREFUSED 127.0.0.1:80
It probably means the Accounts API is not working in node-appwrite, Can someone please help me out here?