This is a simple test script for create a new route:
add_action( 'rest_api_init', function () {
register_rest_route( 'ass', '/ativar', array(
'methods' => 'GET',
'callback' => 'testing_route',
) );
} );
function testing_route($data){
return array( 'message' => 'testing route' );
}
But it returning an error message:
rest_invalid_handler
Solved!
'callback' => __NAMESPACE__ . '\\testing_route',
In my case I was setting up register_rest_route
within a function inside of my class. I simply added:
'callback' => array($this, 'name_of_callback_function),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With