Are you 100% sure that is the exact error? I did a google search for the error and you are the first person in the world to get that specific error message: I also cannot find that error anywhere in livewire or laravel or laravel echo
Sep 21, 2022
9
Level 13
Laravel Echo not working with Livewire
Hi,
I created a livewire component and setup a listener to listen to Pusher notifications and repond. I don't know what wrong I am doing, but component doesn;'t seems to be responding.
Here's the component. Event is firing. I am also getting a warning in console 'Laravel Echo not found'
Livewire Component:
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Events\OrderShipped;
class Welcome extends Component
{
protected $listeners = ['echo:orders,OrderShipped' => 'notifyNewOrder'];
public function notifyNewOrder()
{
logger('Order Shipped');
}
public function render()
{
return <<<'blade'
<div>
Order Status Update
</div>
blade;
}
}
Page:
<head>
@livewireStyles
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
<meta name="csrf-token" content="{{ csrf_token() }}">
</head>
<body>
@livewire('welcome')
@livewireScripts
<script src="{{ mix('js/app.js') }}" ></script>
</body>
App.js
import Echo from 'laravel-echo'
import Pusher from 'pusher-js'
window.Pusher = Pusher
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'c371c727b9e62d57abe1',
cluster: 'mt1',
forceTLS: true,
})
window.Echo.channel('orders').listen('OrderShipped', (e) => {
console.log(e)
})
Please or to participate in this conversation.