Back

[SOLVED] Events disappear after refreshing page

  • 0
  • Flutter
  • Functions
  • Cloud
Shatanik
5 Jun, 2023, 19:07

I understand we need to add the event to appwrite.json. But even after specifying it in json can't add event

TL;DR
Events are disappearing after refreshing the page. The solution is to add the event to the appwrite.json file under the specific function. Make sure to click on "Update" after adding the event.
Shatanik
5 Jun, 2023, 19:08
TypeScript
{
    "projectId": "hidden",
    "projectName": "hidden",
    "events": [
        "databases.*.collections.chat.documents.create"
    ]
}

This is how my appwrite.json looks currently

Drake
5 Jun, 2023, 19:57

can't add event What do you mean?

Shatanik
6 Jun, 2023, 05:04

@Steven I am trying to add an event that will automatically trigger a function when any document inside the chat collection will be created. But as soon as I go to the appwrite cloud and try to create the event through the create event button and put in all details it is added but disappears on refresh

Drake
6 Jun, 2023, 05:23

Events disappear after refreshing page

Drake
6 Jun, 2023, 05:23

Did you click on update after adding the event?

Drake
6 Jun, 2023, 05:24

You definitely should put it in your appwrite.json, but that's the wrong place to put it. It should go under your function

Shatanik
6 Jun, 2023, 05:25

I see, can you guide me to where I can find an example appwrite.json file specific to this

Drake
6 Jun, 2023, 05:28

Did you initialize your function with appwrite init function?

Shatanik
6 Jun, 2023, 05:29

No, I created it directly in cloud and then deploy using appwrite cli

Drake
6 Jun, 2023, 05:33
Shatanik
6 Jun, 2023, 05:34

Thanks @Steven ✨

Shatanik
6 Jun, 2023, 07:13

@Steven I tried putting events under functions but still not working. I even tried creating function using appwrite init function and then adding an event and then updating the function

Shatanik
6 Jun, 2023, 07:14

But everytime the event is sent as empty to the cloud by cli

Shatanik
6 Jun, 2023, 07:14
TypeScript
{
    "projectId": "hidden",
    "projectName": "hidden",
    "functions": [
        {
            "$id": "hidden",
            "name": "createChatCollection",
            "runtime": "dart-2.17",
            "path": "functions/createChatCollection",
            "entrypoint": "lib/main.dart",
            "ignore": [
                ".packages",
                ".dart_tool"
            ],
            "execute": [],
            "events": [           "databases.*.collections.chat.documents.*.create"
            ],
            "schedule": "",
            "timeout": 15
        }
    ]
}

This is how my appwrite.json looks currently

Shatanik
6 Jun, 2023, 07:18

I found out the issue

Shatanik
6 Jun, 2023, 07:18

We need to hit update, even after clicking on create in events

Shatanik
6 Jun, 2023, 07:18

Without update it just vanishes

Shatanik
6 Jun, 2023, 07:20

Create event already has create button, so shouldn't create add the event instead of having to click on two buttons. I think it's a bit confusing for new comers

Drake
6 Jun, 2023, 14:45

how did you "update the function"

Shatanik
6 Jun, 2023, 15:01

I updated from cloud console of appwrite (By clicking add event button)

Drake
6 Jun, 2023, 15:04

if you update in the console, your appwrite.json will be out of sync. i highly recommend updating in your appwrite.json and then deploy with appwrite deploy function

Shatanik
6 Jun, 2023, 15:14

No I understand that, I wanted to say that to update in console we are having to click on three buttons. "+ Add Event" -> "Create" -> "Update". I think if we didn't need to click on the last update button it would have been better from a UX point of view

Drake
6 Jun, 2023, 15:17

[SOLVED] Events disappear after refreshing page

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