Hi, I’m trying to customize the response of an API request with custom data endpoints.
TLDR:
How do I add the dimensions data of a file inside a page to the response of an API request for that page? (The dimensions data is only available if I request the files directly)
Long version:
Is it possible to configure which data is added to the JSON response object? I found out that there are different “views” declared in the …/config/api/models files. I was able to change the “first layer of data” by changing the “compact” view. But I’m having difficulties changing the data that is “embedded”. I found those views through a post by @distantnative in the following thread about a similar topic:
My case: I have a files section on a page. If I specifically request the files on that page using …page(‘my-page’)->files(), then I get the kind of response that I need, since there are all information about the images like dimensions etc. But if I request just the page, which also lists the files in the “content” part of the response, I can only access limited data about the files like url etc, but not the dimensions of the files. Is there a way to edit the data added to the response for files in page requests?
Many thanks in advance!
PS: I hope this is enough context, otherwise I’ll add some code later.