Back

[SOLVED] : AppwriteException: Missing required parameter: "data"

  • 0
  • Web
Binyamin
16 May, 2023, 12:56

Is this the way you're running the function now?

TL;DR
The issue was solved. The solution was to move the reload function inside the deleteTodo function. Additionally, there was a typo mistake in the code. The code was updated to use Appwrite's ID.unique() instead of UDID, and the data parameter was changed to an object. The issue was resolved and the app is now running smoothly.
Susmita
16 May, 2023, 12:57

yes

Binyamin
16 May, 2023, 13:00

Okay. can you run this

  • Change from UDID to Appwrite's ID.unique
  • Change the data to be object.

And check the logs?

TypeScript
import {ID, databases } from '../appwrite/appwriteConfig'

        const data = {todo:todoItem};
        console.log(data);

        const promise = databases.createDocument("ID","ID", ID.unique(), data);

Export ID in appwriteConfig

Susmita
16 May, 2023, 13:03

export database and collection id?

Binyamin
16 May, 2023, 13:03

I mean the ID function But you can do it like this for testing

TypeScript
import {databases } from '../appwrite/appwriteConfig'
import {ID} from "appwrite";

        const data = {todo:todoItem};
        console.log(data);

        const promise = databases.createDocument("ID","ID", ID.unique(), data);
Susmita
16 May, 2023, 13:04

okay, let me try

Susmita
16 May, 2023, 13:10

Hey @Binyamin thanks for your help

Susmita
16 May, 2023, 13:10

didn't have to go through this

Susmita
16 May, 2023, 13:10

just reloaded and restarted the server

Susmita
16 May, 2023, 13:10

and it's up and running automatically

Susmita
16 May, 2023, 13:10

But yes, this was important thing

Binyamin
16 May, 2023, 13:11

So now it works?

Susmita
16 May, 2023, 13:18

Yes but stuck with delete todo item

Binyamin
16 May, 2023, 13:19

What's the issue?

Susmita
16 May, 2023, 13:20

It's not showing any errors and also not deleted the item.

Susmita
16 May, 2023, 13:21

Code:

TypeScript
const deleteTodo = (id) => {
        const promise = databases.deleteDocument("ID", "I", id)
        promise.then(
            function (response) {
                console.log(response);
            },
            function (error) {
                console.log(error);
            }
        )
        window.location.reload()
    }
Susmita
16 May, 2023, 13:21
TypeScript
<div>
                    {todos && todos.map(item => (
                        <div key={item.$id} >
                            <div className="p-4 flex items-center justify-between border-b-2 bg-gray-100 rounded-lg mb-1">
                                <div>
                                    <p>{item.todo}</p>
                                </div>
                                <div>
                                    <span
                                        className="text-red-400 cursor-pointer"
                                        onClick={() => {
                                            deleteTodo(item.$id)
                                        }}
                                    >
                                        Delete
                                    </span>
                                </div>
                            </div>
                        </div>
Binyamin
16 May, 2023, 13:22

The value of the ID's here is just for the example?

TypeScript
  const promise = databases.deleteDocument("ID", "I", id)

Am I right?

Susmita
16 May, 2023, 13:23

yes

Susmita
16 May, 2023, 13:24

actually it's typo mistake

Binyamin
16 May, 2023, 13:25

BTW, because you running it on sync mode it will be better to move the reload function inside the functions

TypeScript
const deleteTodo = (id) => {
        const promise = databases.deleteDocument("ID", "I", id)
        promise.then(
            function (response) {
                console.log(response);
                window.location.reload()
            },
            function (error) {
                console.log(error);
                window.location.reload()
            }
        )
    }
Susmita
16 May, 2023, 13:25

okay

Susmita
16 May, 2023, 13:26

Hey, thanks

Susmita
16 May, 2023, 13:26

Working perfectly now

Susmita
16 May, 2023, 13:28

[SOLVED] : AppwriteException: Missing required parameter: "data"

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