RPC iterate nested array

Hi there!

I have a Join’s custom app.
/categories endpoint returns response like this:

[
  {
    "name": "Administration and Secretariat",
    "slug": "administration_secretariat",
    "subCategories": [
      {
        "id": 233,
        "name": "Administration and Secretariat",
        "slug": "others_administration_secretariat"
      },
      {
        "id": 229,
        "name": "Assistance, Secretarial",
        "slug": "assistance_secretarial"
      },
      {
        "id": 231,
        "name": "Clerk",
        "slug": "clerk"
      },
      {
        "id": 230,
        "name": "Office Management",
        "slug": "office_management"
      },
      {
        "id": 232,
        "name": "Property Management",
        "slug": "property_management"
      }
    ]
  },
  {
    "name": "Design and Architecture",
    "slug": "design_architecture",
    "subCategories": [
      {
        "id": 393,
        "name": "Architecture",
        "slug": "architecture"
      },
      {
        "id": 413,
        "name": "Design and Architecture",
        "slug": "others_design_architecture"
      },
      {
        "id": 395,
        "name": "Graphic Arts and Communication Design",
        "slug": "graphic_arts_communication_design"
      },
      {
        "id": 398,
        "name": "Interior Design",
        "slug": "interior_design"
      },
      {
        "id": 394,
        "name": "Media, Screen and Web Design",
        "slug": "media_screen_web_design"
      },
      {
        "id": 397,
        "name": "Photography, Video",
        "slug": "photography_video"
      },
      {
        "id": 396,
        "name": "Product Design, Industrial Design",
        "slug": "product_design_industrial_design"
      },
      {
        "id": 399,
        "name": "Wood Crafts",
        "slug": "wood_crafts"
      }
    ]
  }
]

my mappable parameters:

{
		"name": "categorySlug",
		"label": "Category",
		"required": false,
		"type": "select",
		"options": {
            "store": "rpc://categories",
            "nested": [
                {
                    "name": "subCategoryId",
                    "type": "select",
                    "label": "Sub Category",
                    "mappable": false,
                    "options": "rpc://subCategories"
                }
            ]
        }
	}

categories rpc:

{
	"url": "/categories",
	"method": "GET",
	"response": {
		"iterate": "{{body}}",
		"output": {
			"label": "{{item.name}}",
			"value": "{{item.slug}}"
		}
	}
}

sub categories rpc:

{
	"url": "/categories",
	"method": "GET",
	"response": {
		"iterate": "{{flatten(get(map(body; subCategories; slug; parameters.categorySlug); 1))}}",
		"output": {
			"label": "{{item.name}}",
			"value": "{{item.slug}}"
		}
	}
}

I need to show all sub categories as options.

Can you help me how to?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.