[Vuejs]-Private channel works with static id but not dynamic vue.js

2👍

The Echo.private call should be done only when you have all the data – in other words, within axios.get().then(...):

axios.get('/messages/' + user_id).then(response => {
   this.conversation = response.data;
   Echo.private('chat.' + this.conversation.conversation_id)
       .listen('MessageSent', (e) => {
         this.conversation.messages.push({
           conversation_id: e.message.conversation_id,
           message: e.message.message,
           name: e.user.firstname
       });
    });
});

Leave a comment