i want to show soon from my API, but it seems not working Below is my code
add_action( 'rest_api_init', 'my_register_route' );
function my_register_route() {
register_rest_route( 'my-route', 'my-phrase', array(
'methods' => 'GET',
'callback' => 'custom_phrase',
)
);
}
function custom_phrase() {
return rest_ensure_response( 'Hello World! This is my first REST API' );
}
i am getting below response
{"namespace":"my-route","routes":{"\/my-route":{"namespace":"my-route","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"namespace":{"required":false,"default":"my-route"},"context":{"required":false,"default":"view"}}}],"_links":{"self":[{"href":"http:\/\/example\/wp-json\/my-route"}]}},"\/my-route\/my-phrase":{"namespace":"my-route","methods":["GET"],"endpoints":[{"methods":["GET"],"args":[]}],"_links":{"self":[{"href":"http:\/\/example\/wp-json\/my-route\/my-phrase"}]}}},"_links":{"up":[{"href":"http:\/\/example\/wp-json\/"}]}}