Setting up the custom endpoints
We will now move on with some practical work, which will consist of us setting up our endpoints. As we have previously stated, routes would only be useful if they have endpoints, which is why the rest of this chapter will only cover the process of adding endpoints to the route using our third argument of register_rest_route()
.
Transport method
The transport method involves endpoints that need to define one or more HTTP transport methods, such as DELETE, POST, PUT, and GET. With an endpoint that is defined as working via a GET request, the REST API will receive the correct data and the way to create errors for invalid requests.
The array that defines your endpoint will further define the transport methods in a key named ...
Get Learning WordPress REST API now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.