How to use category slug to echo a page’s content with the same slug

Worked it out…

<?php $term = get_queried_object(); ?>
<?php   
$page = get_posts([
    'name'      => $term->slug,
    'post_type' => 'page'
]);
if ( $page ){ echo $page[0]->post_content; }    
?>  

error code: 523