1

On my client side, I have an array of entry IDs that match with entries in Craft

const myIds = ['230', '249', '256']

I am trying to send that array over to an Element API endpoint and use it in the id criteria to only grab entries with the specified IDs.

I am constructing my GET request and add myIds to the request parameters, then send it to the endpoint.

How would I access that array in parameters within element-api.php? I found a response for Craft 2 that looks like it's similar to what I want: (Passing multiple parameters to the Element API) which uses the getQuery() or getRequiredQuery() functions, but I'm not sure those still exist in Craft 3?

1

I found a response for Craft 2 that looks like it's similar to what I want: (Passing multiple parameters to the Element API) which uses the getQuery() or getRequiredQuery() functions, but I'm not sure those still exist in Craft 3?

In Craft 3, you'd use:

Craft::$app->getRequest()->getRequiredQueryParam('myArr')

https://docs.craftcms.com/api/v3/craft-web-request.html#method-getrequiredqueryparam

|improve this answer|||||
  • I think I searched for "getQuery" in the v3 docs and didn't turn anything up, thanks a lot for that link, that's exactly what I need. – Graham Bewley Jan 27 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.