Back

[SOLVED] Unable to submit the cartItems to my Database collection.

  • 0
  • Databases
  • Functions
  • Web
Krownwealth_dev
5 Jan, 2024, 15:54

Hello, I have a function that allows logined-in user add items to cart, on add-to-cart click I want the Items to be submitted to the database collection I created. Ihis errors keeps coming up when I clicked on add-to-cart button.

Snip Error from the console: Add-To-Cart funtion: Function that create userItems in my Collection:

TL;DR
Error resolved. The user was experiencing an issue with submitting cart items to a database collection. The issue was caused by missing parameters in the create document function. The solution was to ensure that all four parameters, including the database ID, collection ID, document ID, and data, were properly passed to the function. The correct format for the function was provided as an example in the support thread.
Kenny
5 Jan, 2024, 16:16

const promise = databases.createDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]', [DATA]);

Your create document function should be formatted like above. You're missing a parameter.

https://appwrite.io/docs/references/cloud/client-web/databases#createDocument

Krownwealth_dev
5 Jan, 2024, 16:58

From the createUserItems function it shows I declared all the four params

Kenny
5 Jan, 2024, 16:59

This is what i was looking at

Kenny
5 Jan, 2024, 17:00

Since to me, this seems to be the function that is throwing the error for no data.

Krownwealth_dev
5 Jan, 2024, 17:39

Thank you Kenny error resolved. I noticed I was not passing databaseId, documentId to my try block.

Krownwealth_dev
5 Jan, 2024, 17:40

[SOLVED] Unable to submit the cartItems to my Database collection.

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