How to catch http request errors like when the browser cannot access the internet,
basically i am showing errors when sever returns any, but wen network fails to connect i see no errors
Well I did not understand what you are asking fully, but if you are trying to show some kind of warning to the user that they lost their internet connection, Livewire provides this out of the box
@OussamaMater i have a wire loading and wen the internet is weak, request fails as normal then wire loading stops, no error is shown but user have to know request failed
@OussamaMaterwire:offline just notifies you when the connection is gone. But what to do if there is such a situation:
The user presses the Submit button (a request is sent to the server)
At this moment, the connection disappears (access to the Internet)
We receive:
POST https://foo.com/livewire/message/my_component net::ERR_INTERNET_DISCONNECTED ... Uncaught (in promise) TypeError: Failed to fetch
And after step 3, the application crashes - the component stops working (the Submit button no longer works, the data from the inputs is not transferred to the server).
I think the author asked kakraz about this situation. Not just to tell the user that the application is offline, but to say that perhaps nothing has been saved. Better yet, prevent the app from crashing.
@Prido yes I already answer this, you add a different div to show the error in case of internet loss
<div wire:offline>
<span>you lost your internet connection</span>
</div>
<div wire:loading.class="show" wire:target="store" class="loading-spinner-wrapper">
<span class="spinner-loader"></span>
</div>