REST API: Entry with Entries field #10006
Replies: 3 comments
-
You might need to use a custom resource? https://statamic.dev/rest-api#customizing-resources |
Beta Was this translation helpful? Give feedback.
-
You're correct. Those nested items get the "shallow" values which is just a few important ones plus the API URL if you wanted to grab more data. You can do what Erin suggested and customize the resources. You can also override the classes and customize the shallow augmented keys: https://statamic.dev/extending/augmentation#shallow-augmentation Lastly, you could consider using GraphQL. By its nature, you would get all the values you actually need, all in a single request. |
Beta Was this translation helpful? Give feedback.
-
I have a related question here, it appears that the same entry query through a Content Query does not surface even the shallow nested items. What's the correct way to fetch related data like |
Beta Was this translation helpful? Give feedback.
-
My "Events" collection uses a blueprint where the "Entries" fieldtype is present, to allow related entries (in this case, location.)
I noticed that calling the api endpoint "/api/collections/events/entries" includes the related entries field, but none of it's data aside from the ID, title, and api_url. This means I need to do a recursive API call to fetch the child.
If I'm not mistaken, using plain Laravel I could fetch this using with() (i.e Events::with('location')). I don't see anything in the statamic docs' REST API page about this. Am I missing something or is it not possible without making additional API calls?
Beta Was this translation helpful? Give feedback.
All reactions