mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
Allow plain text response for plugin data polling
This commit is contained in:
parent
882cbff7fe
commit
52dfe92054
2 changed files with 31 additions and 3 deletions
|
|
@ -235,9 +235,15 @@ class Plugin extends Model
|
|||
}
|
||||
}
|
||||
|
||||
// Default to JSON parsing
|
||||
try {
|
||||
return $httpResponse->json() ?? [];
|
||||
// Attempt to parse it into JSON
|
||||
$json = $httpResponse->json();
|
||||
if($json !== null) {
|
||||
return $json;
|
||||
}
|
||||
|
||||
// Response doesn't seem to be JSON, wrap the response body text as a JSON object
|
||||
return ['text' => $httpResponse->body()];
|
||||
} catch (Exception $e) {
|
||||
Log::warning('Failed to parse JSON response: '.$e->getMessage());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue