Back

can't delete an item

  • 0
  • Databases
  • Web
Ajay
2 Apr, 2023, 12:47

const deleteasync = async (id) =>{ console.log(id) const response = await databases.deleteDocument("6427c6d20464df58bf36","6427c6dcd6bc73a91b81","id") response.then( function (response){ console.log(response) }, function (error){ console.log(error) } ) window.location.reload() }

TL;DR
The user is having trouble deleting an item in a React app. They are trying to use `databases.deleteDocument` to delete a document with a specific ID. They are unsure if the ID should be passed as a variable or inside quotation marks. The error they are receiving is "can't find document id." Solution: Make sure the ID is being passed correctly. The correct format for the `databases.deleteDocument` function should be: `databases.deleteDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');`. Verify that the `id` variable is being properly passed as the last argument.
Ajay
2 Apr, 2023, 12:50

The error is can't find document id

darShan
2 Apr, 2023, 13:09

are you passing the document id or just 'id' as the last argument?

darShan
2 Apr, 2023, 13:10

Should be like - databases.deleteDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');

Ajay
2 Apr, 2023, 13:18

It is a document id I am passing the id through click

Ajay
2 Apr, 2023, 13:18

Basically it's an react app

darShan
2 Apr, 2023, 13:25

should it be inside " " then if its a variable? 👀

darShan
2 Apr, 2023, 13:28

It should be const response = await databases.deleteDocument("6427c6d20464df58bf36", "6427c6dcd6bc73a91b81", id);, I guess.

Ajay
2 Apr, 2023, 13:30

Ok will try this also

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