Zsombor
Im trying to implement a liking system, and i dont want the data to be public, but it says user is unauthorized even when the id is right
TypeScript
try {
await databases.createDocument(
appwriteConfig.databaseID,
appwriteConfig.postLikesCollectionId,
ID.unique(),
{
postId: postId,
userId: user.id,
},
[
Permission.read(Role.user(user.id)),
Permission.write(Role.user(user.id)),
Permission.update(Role.user(user.id)),
Permission.delete(Role.user(user.id)),
]
);
} catch (error) {
console.log("Failed to add like", error);
}
TL;DR
Developers are trying to implement a liking system on Appwrite but are facing an issue where the user is unauthorized to access the data, even with the correct ID. The code snippet provided shows the creation of a new document where permissions are set for the user, but it may not be working as expected.
Solution: Check if the user ID being passed is correct and ensure that the user has the necessary permissions. Update the permissions or verify the user's access to resolve the unauthorized issue. Recommended threads
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...
- Edit ID of an existing collection
Hi there. Is it possible to edit an ID of an existing collection? Right now it looks impossible from AppWrite cloud at least.