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
Changing Echo.channel('orders')
to window.Echo.channel('orders')
should fix that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With