WordPress\AiClient\Providers\Http\DTO
Response::getData
Gets the response data as an array.
Attempts to decode the body as JSON. Returns null if the body is empty or not valid JSON.
Method of the class: Response{}
No Hooks.
Returns
Array
Usage
$Response = new Response(); $Response->getData(): ?array;
Changelog
| Since 0.1.0 | Introduced. |
Response::getData() Response::getData code WP 7.0.4
public function getData(): ?array
{
if ($this->body === null || $this->body === '') {
return null;
}
$data = json_decode($this->body, \true);
if (json_last_error() !== \JSON_ERROR_NONE) {
return null;
}
/** @var array<string, mixed>|null $data */
return is_array($data) ? $data : null;
}