recentpopularlog in

dirtystylus : rest   33

8 - How to get $_POST and $_GET parameters - Drupal Answers
passing parameters to a REST API, retrieving them

$query = \Drupal::request()->query->get('name');
drupal  drupal8  REST  api  decoupledcms 
november 2018 by dirtystylus
REST API Best practices: Where to put parameters? - Stack Overflow
Filters always go in the query string, because while they are a part of finding the right data, they are only there to return a subset or modification of what the Locators return alone. The search in (subset) is a filter, and so is /article/5?order=backwards (modification). Think about what it does, not just what it's called!
bestpractices  REST  api  drupal  drupal8  decoupledcms 
november 2018 by dirtystylus
json - Get WP Navigation Menu from REST API V2 - WordPress Development Stack Exchange
Menus are currently not available in the WP Rest. So what you need to do is register your own custom endpoint and then just call that route from your application that needs it.

So you would include something like this (in your functions.php, plugin, wherever):

function get_menu() {
# Change 'menu' to your own navigation slug.
return wp_get_nav_menu_items('menu');

add_action( 'rest_api_init', function () {
register_rest_route( 'myroutes', '/menu', array(
'methods' => 'GET',
'callback' => 'get_menu',
) );
} );
wpapi2  wordpress  api  REST  webdev  decoupledcms 
april 2018 by dirtystylus

Copy this bookmark:

to read