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

prospero's avatar

Cancel API request using Cancel button

Hi guys, already implement the functions to request external API, retrieve data and store it in tables. Also, as the request could be make from diff places I have Livewire component in root layout containing a loading spinner that close the whole window with the spinner animation to avoid the user do any other request on page while the request process. That work like a charm. Now, I'm thinking if is possible to include to that spinner component add a Cancel button if the user decide cut off the process, but really don't know how do it. I'm using the Laravel HTTP facade to make the request. Could you help me on this? Thanks in advance

0 likes
2 replies
fabuy's avatar

Hi, why don't you give the cancel button behavior and have it invoke a method of your livewire that interrupts the execution?

prospero's avatar

Aja, that the idea. The spinner component could have the Cancel button. But how interrupt the execution? The API data retrieve isn't make by this component, this spinner component just is fired once begin the retrieved by other that call the API retrieve class. So, if you could show me how stop that specific API request?

Please or to participate in this conversation.