This content originally appeared on DEV Community and was authored by Morcos Gad
Today we are learning about a feature in Livewire that allows me to fetch data before pressing a key and invoking the api see an example
<div>
<button wire:click.prefetch="getPrice">Show</button>
Price: {{ $price }}
</div>
in livewire component
public function getPrice() {
$this->price = Http::get('') ?? null;
}
I hope you take advantage of this feature
Source :- https://www.youtube.com/watch?v=e2MMO_b0Yj0
This content originally appeared on DEV Community and was authored by Morcos Gad

Morcos Gad | Sciencx (2022-02-01T20:33:52+00:00) Prefetch Data Before Button Click Livewire – Laravel. Retrieved from https://www.scien.cx/2022/02/01/prefetch-data-before-button-click-livewire-laravel/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.