
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
- Issue - Migration From Cloud > Self Host...
Hi team, I’m trying to migrate a few of my Appwrite projects from the cloud to a self-hosted instance. These projects are currently in “archive mode” due to th...
- Why "You’ve reached the limit for your G...
Why did Appwrite send me this alert when the usage reached 10605%? Is it too late? Why not when reached 100% usage? And I can not pay for more usage described ...
- Subdomain failed verification
So I wanted to do a custom subdomain, because local storage doesn't work for me, but I've tried it a long time ago, it didn't work for me, and now I'm trying ag...
