Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Echo - default.a.channel is not a function

I'm trying to setup Laravel Echo with pusher, to implement real time notifications.

First, i have installed Laravel Echo and Pusher:

npm install --save laravel-echo pusher-js

After this, in bootstrap.js i have uncomment the code (as guide say):

import Echo from "laravel-echo"

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'my_key',
    encrypted: true
});
Echo.channel('orders')
    .listen('TestEvent', (e) => {
        console.log('pippo');
    });

I have run gulp and now when i visit the page, i get this error:

bootstrap.js?5e63:50 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_laravel_echo___default.a.channel is not a function
like image 666
Mistre83 Avatar asked Sep 14 '16 07:09

Mistre83


1 Answers

Changing Echo.channel('orders') to window.Echo.channel('orders') should fix that.

like image 181
baikho Avatar answered Nov 05 '22 19:11

baikho