This the output of my GS API Call. I want to get the index position of 8 Jan which in this case is 2.
You can use the built-in function get
e.g.:
{{ get(1.body.values.1; 2) }}
For more information, see the function documentation in the Help Center.
Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —
General
- Help Center | Tutorials
- Make Academy – learn Make and get your certificate
- Discord Server – join us in live chat for fans of Make!
Help Center Basics
- Mapping – What is mapping? What can I map?
- Mapping with arrays – How to map items in an array
- Aggregate an array for mapping complex fields
- Tokens for
parseDate
| Tokens forformatDate
- HTTP modules – Make a request, Get (download) a file
- Webhooks – Error Handling, Responding to webhooks
Articles & Videos
- Router Magic Formula - YouTube
- Error Handlers in Make - YouTube playlist
- Getting started with OpenAI
- How to use Regex in Make
samliew – request private consultation
Join the unofficial Make Discord server to chat with other makers!
It will not be always 8 Jan it is just an example. For the next step i want to get the index of value i pass. something like indexOf(array,“8 Jan”).
There is no indexOf
function for arrays in Make.
The workaround is to Iterate the array, and then create a filter, then you can use the “Bundle order position” variable.
Input
Filter
Output
As you can see, the position of “Jan 15” in the array is 3
.
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!
Module Export
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
-
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
-
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
View Module Export Code
JSON
{
"subflows": [
{
"flow": [
{
"id": 158,
"module": "json:ParseJSON",
"version": 1,
"parameters": {
"type": ""
},
"mapper": {
"json": "{\n \"array\": [\n \"Jan 1\",\n \"Jan 8\",\n \"Jan 15\",\n \"Jan 22\",\n \"Jan 29\"\n ]\n}"
},
"metadata": {
"designer": {
"x": -2316,
"y": -1399
},
"restore": {
"parameters": {
"type": {
"label": "Choose a data structure"
}
}
},
"parameters": [
{
"name": "type",
"type": "udt",
"label": "Data structure"
}
],
"expect": [
{
"name": "json",
"type": "text",
"label": "JSON string",
"required": true
}
]
}
},
{
"id": 160,
"module": "builtin:BasicFeeder",
"version": 1,
"parameters": {},
"mapper": {
"array": "{{158.array}}"
},
"metadata": {
"designer": {
"x": -2073,
"y": -1397
},
"restore": {
"expect": {
"array": {
"mode": "edit"
}
}
},
"expect": [
{
"name": "array",
"type": "array",
"label": "Array",
"mode": "edit",
"spec": []
}
]
}
},
{
"id": 163,
"module": "util:TextAggregator",
"version": 1,
"parameters": {
"rowSeparator": "",
"feeder": 160
},
"filter": {
"name": "filter",
"conditions": [
[
{
"a": "{{160.value}}",
"o": "text:equal",
"b": "Jan 15"
}
]
]
},
"mapper": {
"value": "{{160.`__IMTINDEX__`}}"
},
"metadata": {
"designer": {
"x": -1785,
"y": -1396,
"messages": [
{
"category": "last",
"severity": "warning",
"message": "A transformer should not be the last module in the route."
}
]
},
"restore": {
"parameters": {
"rowSeparator": {
"label": "Empty"
}
},
"extra": {
"feeder": {
"label": "Iterator [160]"
}
}
},
"parameters": [
{
"name": "rowSeparator",
"type": "select",
"label": "Row separator",
"validate": {
"enum": [
"\n",
"\t",
"other"
]
}
}
],
"expect": [
{
"name": "value",
"type": "text",
"label": "Text"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!
Thanks @samliew , I think this will work but how do I convert my body array to json. this is how my array is:
I tried this but i dont think it is a right way.
The first module is just to output an example array.
You can delete it and replace with the module that you showed in your first post.
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!
Thank you so much for the solution and patience @samliew !!