I have a simple page where I'm inserting a message into a message table and then on the frontend detecting it. I have used the sample code provided.
However, everytime, I seem to be detecting 3 events for every insert.
Any ideas?
mounted() {
const channel = supabase.channel('messages');
channel.on(
'postgres_changes',
{
event: 'insert',
schema: 'public',
table: 'messages',
},
(payload) => console.log('payload:', payload)
);
channel.subscribe(async (status) => {
if (status === 'SUBSCRIBED') {
}
});
const res = await supabase.from('messages').insert({
conversationSID: 'CH3165c39d3d784823af47039081fe7c47',
messageSID: '4567',
body: 'hi',
source: 'SDK',
author: 'John',
patNum: 6,
dateCreated: new Date()
});
console.log('inserted',res);
},