1
votes

ArgumentCountError: Too few arguments to function App\Providers\BroadcastServiceProvider::{closure}(), 1 passed in D:\laragon\www\laraveljetstream\vendor\laravel\framework\src\Illuminate\Broadcasting\Broadcasters\Broadcaster.php on line 77 and exactly 2 expected in file D:\laragon\www\laraveljetstream\routes\channels.php on line 21

I am always getting this error . my channels.php

    Broadcast::channel('post{userId}', function ($data,$userId) {
    return response()->json(['user_id' => $userId,'data' => $post]);
});

Component

    protected $listeners = ['echo-private:post.{Auth::user()->id}' => 'notifyNewPost']; 

I was unable to listen to this event . Please suggest some answers. Thanks in advance.

1
Did you mean 'data' => $data instead of 'data' => $post?El_Vanja

1 Answers

0
votes

Isn't because you need a period between post and {userId}?

Broadcast::channel('post.{userId}'...