rest_no_route on custom API endpoint wordpress

This isn’t valid:

add_action('rest_api_init', $b2_items_rest_route->b2_register_route);

By all rights this should generate either a warning or a fatal error

add_action takes a PHP callable as a second parameter, e.g.:

  • 'function_name'
  • function( $im_a_closure_yay) {}
  • array( 'class_name', 'static_method' )
  • array( $object, 'method' )