Create a get all data REST resource

gabrieldev's picture

Hey guys! I have a problem. I want to create a get all data REST resource in Drupal 8. I need a request that will display all the data from all the requests. This request will be executed when the mobile application starts . I found this module:
https://github.com/enzolutions/entity_rest_extra, but I don't know the methods to display all the views with content types that I created. Any solution?

Comments

Here is my quick answer.I

Lowell's picture

Here is my quick answer.

I made a page controller (for the endpoint) that gets all nid's, processes them to extract the data I want in my json, and returns the data as a json response.

<?php
// get all nid's using $key and $value as db-query conditions
\Drupal::entityQuery('node')->condition($key, $value)->execute()
?>

<?php
// return json response
return new JsonResponse($dataArray);
?>

Hope this helps

Business Intelligence

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week