Page()->content() is `null` in custom API response

To be honest, at first look I am not sure how the response is exactly resolved internally and why those fields and up as null and not actual data. What happens when your return page('PATH/' . $uid)->children() directly and not wrapped in an array?

But since you were mentioning headless-backend, I was wondering if you have had a look at GitHub - getkirby/kql: Kirby's Query Language API combines the flexibility of Kirby's data structures, the power of GraphQL and the simplicity of REST. which might make your use case a lot easier.

Another way could also be Content representations | Kirby CMS for the parent page that directly returns JSON for all children.

Just thinking that this might be the easier tools to get the consumable data for your frontend.

1 Like