dimanche 15 décembre 2019

Laravel Echo not listening pusher events

I tried to build my own pusher/vue js real time chat application. MessageSent Event Broadcasting working but it can't be listen from Laravel Echo. How can i fix this :(

Here is my Chat component code

< script >


  export default {


    props: [
      'receiver_id',
      'sender_id'
    ],

    data() {
      return {
        message: null,
        messages: [],

      }
    },

    mounted() {
      window.Echo.private('chat.' + this.sender_id + '.' + this.receiver_id)
        .listen('MessageSent', (e) => {
          console.log(e)
        });

      axios.post('/get-messages', {
          receiver_id: this.receiver_id
        })
        .then(response => {
          this.messages = response.data
          // console.log(this.messages)
          // console.log(this.receiver_id)
          // console.log(this.sender_id)
        })
        .catch(e => {
          console.log(e)
        })


    },
    methods: {
      formSubmit(e) {
        e.preventDefault();
        axios.post('/send-message', {
            message: this.message,
            receiver_id: this.receiver_id
          })
          .then(response => {
            this.messages.push(response.data)
            // console.log(response)
          })
          .catch(e => {
            console.log(e)
          })
        event.target.reset()
        this.message = null
      },

    }


  }

  <
  /script>

I need your help to fix this issue. pusher log

I tried too much time for fix this but i'm failed every time.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire