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
});
});
});
Source:stackexchange.com