Pankaj
Pankaj

Reputation: 10115

Issue in window.Echo

I am following this tutorial to implement Pusher in Laravel 5.4

Below were the step by step things done.

  1. composer require pusher/pusher-php-server
  2. npm install --save laravel-echo pusher-js
  3. instantiated the Echo instance in your resources/assets/js/bootstrap.js
  4. Initialized the pusher key in env and in bootstrap.js file.

Finally, I wrote below code in blade.

<script>
    debugger;
    window.Echo.channel('SendMessageChannel.1')
        .listen('.App.Events.SendMessageEvent', (e) => {
            console.log(e);
        });
</script>

also added <script src="{{ asset('js/app.js') }}"></script> reference in layout. While debugging, I found that window.Echo is undefined.

Am I missing anything?

Upvotes: 2

Views: 3691

Answers (1)

Parth Vora
Parth Vora

Reputation: 4114

Once you install laravel-echo and pusher-js, you need to run npm run dev so that app.js can have those both libraries.

Upvotes: 2

Related Questions