Back

[SOLVED] Realtime Subscriptions - callback doesnt log?

  • 0
  • Self Hosted
  • Web
Camo
7 Feb, 2024, 15:30

This should log the response, right? Well it doesn't. I see the connection in the network tab, it's alive and healthy. Any ideas?

TypeScript
function callback(response){
        return console.log(response)
    }

    const unscribe = appwrite.client.subscribe('dashboard', callback);

    beforeNavigate(to => {
        unscribe()
    })```
TL;DR
Developers were experiencing an issue where the callback function for a Realtime Subscription was not logging the response. The solution was to ensure that the correct collection name was used in the subscription function. The correct code should be: ```js appwrite.client.subscribe('databases.*.collections.dashboard', callback); ``` The developer also confirmed that everything else was set up correctly, and there was a successful connection. After some debugging, they realized that they were mistakenly using the wrong collection name in the subscription function.
Camo
7 Feb, 2024, 15:39

Images confirming that everything is set as it should be? and we indeed are connected

Kenny
7 Feb, 2024, 15:51

is dashboard the name of your collection?

Kenny
7 Feb, 2024, 15:51

Would it not be

TypeScript
appwrite.client.subscribe('databases.*.collections.dashboard', callback);
Camo
7 Feb, 2024, 15:52

yes, i'm so sorry, i just figired that out while you were writing ))

Camo
7 Feb, 2024, 15:52

added for test individual document, everything works just fine, god damn me old fool, always blind to obvious things

Camo
7 Feb, 2024, 15:53

thank you @Kenny

Kenny
7 Feb, 2024, 15:54

Glad you figured it out! :)

Kenny
7 Feb, 2024, 15:54

[SOLVED] Realtime Subscriptions - callback doesnt log?

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