laravelecholaravel-echo

laravel Echo --> Cannot read property 'channel' of undefined


iv been trying to solve this since morning...i keep get this error..

vue.js:1743 TypeError: Cannot read property 'channel' of undefined 

i am trying to listen on a channel using this code.i already tried using Echo.channel that didn't work so am using the code below which also seem go generate the error i mentioned

listen(){
window.Echo.channel('tmp-chanel')
.listen('NewBidMade',(auction_item) => {
console.log('-------wakanda-------');
// this.item = auction_item;
});
},

any ideas or possible solutions are welcome


Solution

  • My problem was that my script tag had the defer attribute. Removing it fixes the problem with the script.

    <script src="{{ asset('js/app.js') }}" defer></script>