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

sk8rboi7566's avatar

Refresh a view when an API endpoint has recieved a POST request?

I have a webhook that i have connected to my API endpoint as a POST route:

Route::post('/webhook',[ApiController::class, 'update']);

I am able to see what is being sent over with beeceptor. But i am confused on how to display the data that is being sent over on my website itself or even a simple dd()

Once i capture a certain key value, i am wanting to refresh a certain view page, passed with that response data.

Is that even possible?

0 likes
5 replies
tykus's avatar

The webhook is typically headless; and a different session to the one that may have requested the certain view page. Would a user be visiting the page whenever the webhook was received?

You could broadcast an event whenever the webhook is received, and have a (Larave Echo) listener on the web page to refresh the page.

https://laravel.com/docs/8.x/broadcasting

martinbean's avatar

@sk8rboi7566 What has a webhook got to do with a page?

Explain the problem you’re trying to solve. Not how you’re trying to solve it.

sk8rboi7566's avatar

@martinbean here is my problem:

  • webhook listens for event
  • event gets fired to update x page
  • person on x page has part of the page update in "real-time"
Snapey's avatar

In a normal request cycle, data is sent to the client in response to a request

When the client is not requesting anything then nothing can be sent to client. There are two methods of dealing with this;

polling: the client (using javascript) keeps asking the server if it has any new data. You can also implement polling with Livewire without needing any javascript expertise.

Websockets: the client registers an open web socket with a websocket server like pusher, the server can broadcast to all the clients that are listening. See Laravel Echo.

Please or to participate in this conversation.