First you need to [register_rest_fields][1] to adding custom endpoints in WP REST API JSON Response
add_action( 'rest_api_init', 'add_custom_fields' );
function add_custom_fields() {
register_rest_field(
'post',
'custom_fields', //New Field Name in JSON RESPONSEs
array(
'get_callback' => 'get_custom_fields', // custom function name
'update_callback' => null,