Hello everyone,
I am building a custom module in Make.com that receives a response from an API in the form of a JSON object containing an array (key name: items
). I want each item in the array to become a separate bundle for further processing. For example, if the JSON looks like this:
{
"items": [
{ "id": 1, "name": "Item 1" },
{ "id": 2, "name": "Item 2" }
]
}
I want each item in the items
array to be output as a separate bundle.
How can I configure the module so that each item in the array is turned into its own bundle? Is there any example code that demonstrates how to do this correctly?
Thank you very much for your help!
to correctly set up your custom module in Make, you should use the iterate
and output
directives within your module configuration. This configuration will enable you to handle each item in an array as a separate bundle for further processing.
Given your JSON example:
{
"items": [
{ "id": 1, "name": "Item 1" },
{ "id": 2, "name": "Item 2" }
]
}
Here’s how to configure your custom module to process each item in the items
array as a separate bundle:
- Iterate Directive: You need to specify where the module should iterate. Assuming the array you want to iterate over is directly under the JSON response body and named
items
, your iterate
directive should point to body.items
.
- Output Directive: You specify how you want each output bundle to be structured using the item variable to access properties of each iterated object.
Here’s the configuration snippet for your custom module:
{
"response": {
"iterate": "body.items",
"output": {
"id": "{{item.id}}",
"name": "{{item.name}}"
}
}
}
In this setup:
- The
iterate
directive tells the module to loop over each object in the items
array.
- The
output
directive defines how the output for each iterated item should be structured. Each output bundle will include the id
and name
of each item.
This setup ensures that each item in the items
array is processed as an individual bundle, allowing further actions to be performed on each item separately in your Make scenario.
here is another example using the make api
Results
3 Likes
Thank you!! This solution solved my problem
3 Likes