Site icon Hip-Hop Website Design and Development

Require()/Include() post template adding extra content

I’m using a WP endpoint to request additional post HTML via Javascript. When I query the Endpoint using Postman I’m seeing additional content added to the markup and it’s not anywhere in my code. I have a feeling it’s PHP erroring but I can’t figure out what the problem is.

function get_post($data)
{
    global $post;
    $post = get_post($data['id']);
    $previous_post = get_previous_post();
    $post = $previous_post;
    $markup = include('includes/template.php');
    return $markup;
}
add_action('rest_api_init', function () { // Add API endpoint on init
    register_rest_route('query-post', '/post/(?P<id>d+)', array( 
        'methods' => 'GET',
        'callback' => 'get_post',
        'permission_callback' => '__return_true'
    ));
});

What is being returned from the API is my rendered template with correct post data, but there is a random 1 at the end of the markup.

<div class="post">
    Hello World!                            
</div>1