Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

andrecuellar's avatar

How to emit from livewire component to console.log browser

Hello, I have this code in my livewire component

            $franchiseList = $this->getFranchiseList();

I would like to emit $franchiseList to the browser

I tried by adding this to my component

            $this->emit('getFranchiseList');

and this to my blade-view component

    <script>
        let data = null;

        document.addEventListener('livewire:load', () => {

        @this.on('getFranchiseList', () => {

            data = @this;
            console.log(data);
        })

        })
    </script>

but I only get this on the console

Proxy {}

How can I get the result of getFranchiseList to the console?

the return type is

Illuminate\Pagination\LengthAwarePaginator {#1474 ▼
  #items: Illuminate\Database\Eloquent\Collection {#1422 ▶}
  #perPage: 10
  #currentPage: 1
0 likes
3 replies
jlrdw's avatar

You should see in the network tab. For screen, place result in a div.

Romiale's avatar

You can use this: $this->js("console.log(franchiseList)");

Please or to participate in this conversation.