Hi,
thanks for your response!
Based on your example, I created an endpoint '/api/search' and this is the get handler I have:
protected function getHandler() {
header('Content-Type: application/json');
$query = $_GET['q'];
$query = 'Contact Us';
$query_result = SiteTree::get()->filterAny([
'Title' => $query,
'Content' => $query
])->toArray();
$result = array(
"result" => $query_result
);
// output data in json format.
echo json_encode($query_result);
die;
}
Problem I have it returns one record in this case but doesnt return all object fields. Output Example:
[
{
"destroyed": false,
"class": "Page"
}
]
I'm missing something? Also is there a way to paginate this result?
Thanks!