wordpress api make 2 custom post type with single request

Please write function for get post by title

function get_page_by_post_title( $page_title, $output = OBJECT, $post_type="page" ) {
    global $wpdb;

    $sql = $wpdb->prepare(
        "
        SELECT ID
        FROM $wpdb->posts
        WHERE post_title = %s
        AND post_type = %s 
        ORDER BY ID DESC
    ",
        $page_title,
        $post_type
    );

    $page = $wpdb->get_var( $sql );

    if ( $page ) {
        return get_post( $page, $output );
    }
}

And this is your inquire_id function like,

function get_inquiry_id($data){ 
    $return = []; 
    $title=$data['title']; 
    $return = get_page_by_post_title($title, OBJECT, 'inquiry'); 
    $return = $return->ID; 
    return new WP_REST_Response($return, 200); 
}

error code: 523