Can you try like this?
window.Echo.channel("change-price." + this.productId).listen(".ChangePrice", (event) =>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
My pusher and broadcast setup seems working because I can see the API Message on Pusher's debug console yet I cannot listen to the broadcast. This is how I setup it on my VueJS 2 Component. Thank you for any answers or response.
import Echo from "laravel-echo";
window.Pusher = require('pusher-js');
const echo = new Echo({
broadcaster: 'pusher',
key: 'my key',
cluster: 'my cluster',
encrypted: true,
authEndpoint: 'pusher/auth',
auth: {
headers: {
Authorization: 'Bearer ' + localStorage.getItem('token')
},
}
});
// this is under my methods component and I call it on mounted
listenForPrivateChannelEvents() {
try {
echo.channel(`change-price.${this.productId}`)
.listen('ChangePrice', (event) => {
this.handlePriceChange(event.productId, event.newPrice);
});
} catch (error) {
console.error("Error subscribing to private channel:", error);
}
},
handlePriceChange(productId, newPrice) {
console.log(`Price for product ${productId} changed to ${newPrice}`);
},
Ok I see that you use vue CLI 5 Also Echo is a feature from Laravel but because your vue2 and laravel are separated this doesn't work. You should use the js examples from pusher documentation.
What is the goal you currently want to achieve by using pusher? Think about if its not possible to just use axios calls for this.
Also because you're using a private channel make sure to add private- infront of the event name like this private-change-price
In this event the channel name is also different than the channel you use in your js script Make sure to also broadcast an event for change-price
public function broadcastOn()
{
$channel = new PrivateChannel("book-a-job.{$this->bookingId}");
Log::info('Broadcasting on channel:', ['channel' => $channel]);
return $channel;
}
Check these links from Pusher documentation: Pusher JS Quickstart: https://pusher.com/docs/channels/getting_started/javascript/
Use case on how to authenticate pusher for your project: https://pusher.com/docs/channels/getting_started/javascript-realtime-user-list/
Please or to participate in this conversation.