I have an issue.I am accessing my pusher info from .env file through process.env.VARIABLE_NAME inside bootstrap.js(As defined inside laravel Docs in broadcasting section), but it gives me an error.I am working on laravel Pusher with VueJs.
bootstrap.js
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
Vue.prototype.$echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    forceTLS: true
});
My Vue File
    mounted() {
        Vue.prototype.$echo.private('expense')
        .listen('ExpenseNotification', (e) => {
            console.log('irfan ullah shakir');
        });
    }
Error:
[Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'private' of undefined"
Code works fine to broadcast event to pusher, but have problem in receiving through 'Echo' inside vue mounted hook
 

 
    
Top comments (8)
Just gotta ask,
Echois installed right?npm install --save laravel-echo pusher-js? As for the comment below,Presence Channelsareprivate channelsEvent receiving in Pusher: dev-to-uploads.s3.amazonaws.com/i/...
Ys, Echo is Installed
Package.json: dev-to-uploads.s3.amazonaws.com/i/...
Hy, I found solution.I just paste
inside
app.jsand it is working fine now.Second, I changedVue.prototype.$echotowindow.Echoinside bothapp.jsandVue mounted Hook(where I am listening channel).On the sample in Laravel Doc it assigns the Echo to window.Echo. laravel.com/docs/7.x/broadcasting#...
Have you tried this way?
It gives me an error: "Echo is not defined", I also tried window.Echo
replace Echo.channel with window.Echo.channel......
The link you sent is for
Presence ChannelsI am usingprivate channelslaravel.com/docs/7.x/broadcasting#...