1

I've got a frontend form which queries the openstates.org API to return a given set of data objects.

Those objects also exist in Craft as entries, and the API data includes a field that serves as a unique ID for the Craft entries - how can I pass those unique IDs back to the Craft template to retrieve the corresponding entries?

mierla
  • 43
  • 1
  • 8

1 Answers1

2

Per Michael's suggestion above, with some help from this answer, I passed the results from the API call back to a craft template as query params, so it looked like this (simplified):

{% if craft.request.isAjax %}
    {% set myReps = craft.request.getParam('personId') %}
    {% set myIds = myReps | split(',') %}
    {% for myId in myIds %}
        {% set person = craft.entries.section('representatives').repId(myId).first() %}
    {% endfor %}
{% endif %}

and then output my info from there.

mierla
  • 43
  • 1
  • 8