Error : DataService :: getExpenses :: error: AppwriteException: Server Error at Client.<anonymous> (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=60898c8d:850:17) at Generator.next (<anonymous>) at fulfilled (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=60898c8d:488:24)
please help i need to retirve specific user data by using their userId code :
async saveExpense({ expenseName, expense, expenseDate }) {
try {
const userId = localStorage.getItem('userId');
if (!userId) {
throw new Error("User not authenticated");
}
const data = {
userId,
expenseName,
expense,
expenseDate
};
return await this.databases.createDocument(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
ID.unique(),
data
);
} catch (error) {
console.log("DataService :: saveExpense :: error: ", error);
throw error;
}
}
async getExpenses() {
try {
const userId = localStorage.getItem('userId');
if (!userId) {
throw new Error("User not authenticated");
}
const response = await this.databases.listDocuments(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
['*'],
100,
0,
`userId=${userId}`
);
return response.documents;
} catch (error) {
console.log("DataService :: getExpenses :: error: ", error);
throw error;
}
}
}
const dataService = new DataService(); export default dataService;
Are you sure database ID is correct?
Also what's userID=${userId} for?
yes i am
userid is to retrieve data entered by specific user
Do you have an attribute with the user ID?
If so, it should be like this:
const response = await this.databases.listDocuments(
conf.appwriteDatabaseId,
conf.appwriteCollectionId,
[
Query.limit(100),
Query.equal("userID",[userId]),
],
);
Recommended threads
- Project Paused Despite Daily Active Usag...
I noticed that my project was automatically **paused**, even though it is actively being used. The project is an **attendance application** that is used daily b...
- Sudden CORS Errors - Domain hasn't Chang...
I have an Appwrite project with two web apps configured, the first one has the hostname `*` and the second one I just added to test if it could fix the issue wi...
- Any way to temporarily bypass the email ...
Hey guys, any way to bypass the email verification to use the accounts again? i need to recover some projects that due to recent changes have been stopped, and ...