[Vuejs]-Socket IO client should be globally available error

0👍

I guess I found the way that works for unknown reason 😀

import Echo from ‘laravel-echo’

if (process.client) {
  window.io = require('socket.io-client')
}

And then

mounted() {
  let echo = new Echo({
    broadcaster: 'socket.io',
    host: 'http://seekers-backend.com:6001',
    auth: { headers: { Authorization: this.token } }
  })
  echo.private('user.' + this.$auth.user.id)
  .listen('MessageEvent', (e) => {
    // Do stuff
  })
}

Leave a comment