Back

Updating a CRUD app

  • 0
  • Databases
  • Web
teri
3 May, 2023, 23:02

I am getting this error every time I make changes to the text in the input field using the modal component.

Here is my code using the Update document databases API.

TypeScript
const updateTodo = (database_id, collection_id, document_id) =>
  databases.updateDocument(database_id, collection_id, document_id);

const handleUpdateTodo = () => {
  updateTodo(
    props.item.$databaseId,
    props.item.$collectionId,
    props.item.$id
  ).then(
    function (response) {
      console.log(response);
    },
    function (error) {
      console.log("Error updating the document", error.message);
    }
  );
};
TL;DR
The user is trying to update a CRUD app but is encountering an error. They are missing the 4th argument to `updateDocument()` function. The error is happening when making changes to the text in the input field using the modal component. The data does not persist after refresh. It seems that the user is not passing the data to update correctly. Here is their code: ``` const updateTodo = (database_id, collection_id, document_id) => databases.updateDocument(database_id, collection_id, document_id); const handleUpdateTodo = () => { updateTodo( props.item.$databaseId,
teri
3 May, 2023, 23:04

It changes the text, but on refresh, the data doesn't persist both on the browser and in the database.

Drake
3 May, 2023, 23:49

yoiu're not passing the data to update...

teri
4 May, 2023, 02:33

How should I do it?

teri
4 May, 2023, 02:34
TypeScript
<form
      class="form u-width-full-line u-max-width-500 u-flex u-main-center"
      @submit.prevent="handleUpdateTodo">
Drake
4 May, 2023, 02:36

You're missing the 4th argument to updateDocument()

teri
4 May, 2023, 02:42

Hmm.

Drake
4 May, 2023, 02:53

Still, you're missing the 4th argument to updateDocument()

teri
4 May, 2023, 02:56

Ok. Where exactly can I fix it on? It is only this part that is still disturbing me.

Drake
4 May, 2023, 02:56

Line 82...

teri
4 May, 2023, 03:08

Got it. Thank you so much.

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