Headless API - Get all Regions

  • Hi, is there an easier way to grab all regions of a page using the Headless API, rather than adding them all to a set?


    The following doesn't work but shows what I'm after:




    It works doing the following but isn't as futureproof as I'll have to add it into the API each time if I add a region:


    Code
    1. $Set->add_items($Regions->query('Header Block', [
    2. 'page' => '/about-page',
    3. ]));
    4. $Set->add_items($Regions->query('Block One', [
    5. 'page' => '/about-page',
    6. ]));


    Thanks.

  • drewm

    Approved the thread.
  • To keep Headless stuff in one thread. I'm grabbing 7 regions from one page which is working fine. However one of the regions has 7 items - but these are indistinguishable in the returned JSON. It returns 13 items in the array. I assumed it would return 7 items, but with the first item having 7 more items within it.


    The issue is the region that has multiple items, can have extra items added to it, so I can't grab anything based on ID. I've attached a couple of screenshots that may show the problem.




    Is there a quick solution to this do you know? Last resort I'll have it as 1 region with the element repeatable within it.

  • Yeah I think so!


  • You're putting them all into the same set. Put them in their own sets.