I have a plugin that I'm working on, and the endpoint is behaving oddly. I'm getting the error mesage seen in the title of this post; I have noted past threads that reference similar problems, but there aren't any helpful solutions there. My code:
function get_awesome_params( WP_REST_Request $request ) {
$parameters = $request->get_params();
return new WP_REST_Response($parameters, 200);
}
add_action('rest_api_init', function() {
register_rest_route('cbd/v1', '/cbdproducts', array(
'methods' => WP_REST_SERVER::CREATABLE,
'callback' => 'get_awesome_params',
'args' => array(),
'permission_callback' => function () {
return true;
}
));
});
If I remove the typing and just pass in '$request', then it thinks it's just a string and the getter called in the function doesn't work.