I need to return two types of entry to an external service, and am trying to do so in one endpoint.
I am able to return all of the instances of each type, but it returns an array of mixed types.
"api/myEndpoint" => function() {
return [
"criteria" => [
"type" => ["typeOne", "typeTwo"],
],
"transformer" => new MyTransformer()
];
}
I'm trying to achieve: { "data": { "typeOne": [{...}, {...}], "typeTwo": [{...}, {...}]}}
I can think of various workarounds for this specific case. It would be easy enough to add a type field within the Transformer, and sort them on the other side. Or, simply make two calls. However, our team was planning on using Craft as a headless CMS for future projects, and it's important to me be able to control the structure of Element API's JSON response.