How to send an array of categories and posts in wordpress functions.php?

I make a request to my custom endpoint function in functions.php : add_action( ‘rest_api_init’, function () { register_rest_route( ‘wp/v2’, ‘/homepage/’, array( ‘methods’ => ‘GET’, …