mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat(#46): added support for request body in recipes
This commit is contained in:
parent
3673654df6
commit
e326ded933
7 changed files with 130 additions and 19 deletions
|
|
@ -56,9 +56,19 @@ class Plugin extends Model
|
|||
}
|
||||
}
|
||||
|
||||
$response = Http::withHeaders($headers)
|
||||
->get($this->polling_url)
|
||||
->json();
|
||||
$httpRequest = Http::withHeaders($headers);
|
||||
|
||||
// Add body for POST requests if polling_body is provided
|
||||
if ($this->polling_verb === 'post' && $this->polling_body) {
|
||||
$httpRequest = $httpRequest->withBody($this->polling_body);
|
||||
}
|
||||
|
||||
// Make the request based on the verb
|
||||
if ($this->polling_verb === 'post') {
|
||||
$response = $httpRequest->post($this->polling_url)->json();
|
||||
} else {
|
||||
$response = $httpRequest->get($this->polling_url)->json();
|
||||
}
|
||||
|
||||
$this->update([
|
||||
'data_payload' => $response,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue