I'm having a problem accessing my users collection to list all my users. I was having trouble creating users but it has been resolved. I'm using react/nodejs on localhost. Please let me know what you need to see from my code or my IDE to fix this issue.
@Soulfisher Hi, I am SillyDryCoder. From what you've described, here's a clarified breakdown of the issue and what needs to be checked:
Problem Summary You’re trying to list all users from your Appwrite project using React/Node.js on localhost. You resolved the user creation issue, but now you can’t access the users collection to list users.
Important Appwrite Context
🟨 In Appwrite, listing users is not possible from the Client SDK (i.e. from frontend React apps). ✅ It requires server-side access via Appwrite Admin SDK or the Appwrite Node.js SDK with API key & project permissions.
Here are scenarios you could be stuck on: ✅ Option A: Server-Side Access using Node.js Admin SDK Use the official Appwrite Users API via Node.js backend with an API key that has users.read scope.
❌ Option B: Frontend Access using Client SDK (React, etc.) Not allowed — Appwrite Client SDKs do not support listing all users for security reasons.
*� Option C: Custom Users Collection If you created a custom Appwrite database collection named "users" (or similar), then: Each user would need to be added manually (e.g., at sign-up). You can use Databases API to list documents in this collection, even from the frontend, if permissions allow.
Assuming you're using Node.js (backend) for fetching users: You must use the Users API:
`import { Client, Users } from 'node-appwrite';
const client = new Client() .setEndpoint('http://localhost/v1') // your Appwrite endpoint .setProject('PROJECT_ID') // your project ID .setKey('API_KEY'); // your API Key (with user.read scope)
const users = new Users(client);
(async () => { try { const allUsers = await users.list(); console.log(allUsers); } catch (err) { console.error('Error listing users:', err); } })();`
🔴 If you're trying to do this in a frontend (like React) using the Account API — it will not work.
Reference: https://appwrite.io/docs/products/auth/users
I have included a screen shot of my env file and the code I'm using to retrieve the data:
export const getAllUsers = async (limit: number, offset: number) => { try { const { documents: users, total } = await database.listDocuments( appwriteConfig.databaseId, appwriteConfig.userCollectionId, [Query.limit(limit), Query.offset(offset)] )
if (total === 0 ) return { users: [], total }
return { users, total };
} catch (e) {
console.log('Error fetching users', e);
return {users: [], total: 0 }
}
}
The name of my the collection that I'm trying to get the data from is 'users'.
From my view users page
export const loader = async () => { const { users, total } = await getAllUsers(10, 0);
return { users, total };
}
I blacked out my credentials. If you need to see them please let me know.
try manually passing the params to listDocuments or print the values of appwriteConfig.userCollectionId and appwriteConfig.databaseId via console.log. See there's no empty string or a typo.
Here's the error message that I'm getting:
Error fetching users: AppwriteException: Missing required parameter: "collectionId" at Databases.listDocuments (file:///Users/cassandracook/Code/tourvisto/node_modules/appwrite/src/services/databases.ts:26:19) at getAllUsers (/Users/cassandracook/Code/tourvisto/app/appwrite/auth.ts💯53) at loader (/Users/cassandracook/Code/tourvisto/app/routes/admin/all-users.tsx:15:50) at callRouteHandler (file:///Users/cassandracook/Code/tourvisto/node_modules/react-router/dist/development/chunk-DQRVZFIR.mjs:10239:22) at commonRoute.loader (file:///Users/cassandracook/Code/tourvisto/node_modules/react-router/dist/development/chunk-DQRVZFIR.mjs:10388:25) at actualHandler (file:///Users/cassandracook/Code/tourvisto/node_modules/react-router/dist/development/chunk-DQRVZFIR.mjs:4128:14) at file:///Users/cassandracook/Code/tourvisto/node_modules/react-router/dist/development/chunk-DQRVZFIR.mjs:4139:91 at runHandler (file:///Users/cassandracook/Code/tourvisto/node_modules/react-router/dist/development/chunk-DQRVZFIR.mjs:4144:7) at callLoaderOrAction (file:///Users/cassandracook/Code/tourvisto/node_modules/react-router/dist/development/chunk-DQRVZFIR.mjs:4191:22) at Object.resolve (file:///Users/cassandracook/Code/tourvisto/node_modules/react-router/dist/development/chunk-DQRVZFIR.mjs:4014:16) { code: 0, type: '', response: '' }
that simply means that the value of collectionId is not valid. verify the value of the collectionId that you are passing is correct. do a print via console.log or similar right before listDocuments to see the values.
It says undefined
But the page says no records found
means the collection id value doesn't exist. sdk is correct to throw an error.
Maybe just check your .env stuff. Or the code handling around this.
@Soulfisher
I verified the env ids from appWrite. Now the storeUser function is not hitting the collection either and its not throwing any errors. Here's my client file:
import {Account, Client, Databases, Storage} from "appwrite";
export const appwriteConfig = { endpointUrl: import.meta.env.VITE_APPWRITE_API_ENDPOINT, projectId: import.meta.env.VITE_APPWRITE_PROJECT_ID, apiKey: import.meta.env.VITE_APPWRITE_API_KEY, databaseId: import.meta.env.VITE_APPWRITE_DATABASE_ID, userCollectionId: import.meta.env.VITE_APPWRITE_USERS_COLLETION_ID, tripCollectionId: import.meta.env.VITE_APPWRITE_TRIPS_COLLECTION_ID }
const client = new Client() .setEndpoint(appwriteConfig.endpointUrl) .setProject(appwriteConfig.projectId)
const account = new Account(client); const database = new Databases(client); const storage = new Storage(client);
export { client, account, database, storage };
Here's a link to my repo: https://github.com/soulfisher/travel-agency-dashboard
Could this issue be because of the name of the collection?
Maybe not. if its correct.
I see your code. That's neat with no issues in my POV. Just check a few more things below IG.
- Check Collection Permissions
Go to Appwrite console → Database → Collection → Permissions Ensure it allows write access for: *
role:authenticated(if using user session) * or your API key (if usingsetKey()) - Validate Collection Attributes
Make sure all fields (
accountId,email, etc.) exist with correct types in the collection schema. - Log Document Creation
console.log("Created user:", createdUser);Helps catch silent failures or undefined returns.
- Enable Appwrite Logger
client.setLogger({ log: console.log, error: console.error });See request logs and potential hidden errors.
- Ensure
storeUserData()is CalledConfirm it runs after login and isn’t skipped due to logic or redirect.
- I'm using an API key and I have given the collection all permissions for ANY.
- I have validatedfields are the same as the collection attributes.
- I get the 'Missing parameter' error for getUser, getExistingUser and storeUserData functions. These errors are almost immediate fired (there is no wait time).
- How do I implement this?
- storeUserData is being called - get the same error.
Hi everyone,
Thanks for all your help. I finally fixed it. I had a typo that I just found this morning.
Cassandra 😀
Recommended threads
- SPA Not working
So I'm using vite/react, which is spa, and it used to work before, but now whenever I go to any route except the root it shows appwrites 404 page, instead of us...
- Issue with downloading large files (40GB...
Hi everyone! I am using the latest Appwrite 1.8.0 version on my self-hosted server. I successfully uploaded a large ZIP archive (~40GB) using the chunked uploa...
- Cant get realtime working
Hey I nned some help with realtime a gain. I was using client.subscribe(...), and i found out that its depricated then i believe realtime.subscribe(...) is the ...