Back

Error in uploading comment to database. (Cant fetch user ID)

  • 0
  • Databases
rudra_2001
6 May, 2024, 10:24

So I am building a project management web app with react and next js and using appwrite as my backend. I am getting an error in uploading comment to this database. I have put all the auth functionalities into a context hook so that I can extract them whenever I want to use them. Here is the auth context function, I use a custom hook for later usage.

TL;DR
Developers are facing an issue with uploading comments to a database due to the inability to fetch the user ID. The problem persists despite changing the tech stack. The error occurs when trying to pass the user ID extracted from state variables to the database. There's a context hook-based approach in place for database functionality. The user ID is successfully retrieved in the console but throws an error when passed to the database schema. The project involves building a web app with React and Next.js, utilizing Appwrite as the backend. Solution: Recheck the code where the user ID is extracted and passed to the database schema, ensuring it is done correctly with
rudra_2001
6 May, 2024, 10:26

I use a state variable to track the session and the current logged in users credentials. Later I extract it in other components so that I can get the user ID. I can get the user ID in the console but for some reason when I extract it in the code and pass it on as a schema to the DB it gives an error that the user ID is missing. Here are the images of the error and user ID in my code.

rudra_2001
6 May, 2024, 10:31

Now here is some more code. I also use a context hook based approach to pass on the functionalities of a database to child components whenever they need to. Then I extract the funcitionality and then try to pass it to the database like the code img given below.

rudra_2001
6 May, 2024, 10:36

Now here are some screenshots of the networks tab and the pattern of the collections in the DB.

rudra_2001
6 May, 2024, 10:37

I know this is a very long question but I have been dealing with this for the last two months, I even changed my tech stack because of this dumb error and it still does not go away

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more