I am very new to retool and coding. I have built an API call which returns a list of template information. I would like to use this response to create an array for a "select" component. My goal is to call the API to get a list of template names and the corresponding ID, feed that to a "select" component and then use the selected ID to update a variable.
My API response is:
[
{
"id": "525",
"name": "1.5"x.5" Shelf Tag w/Price",
"description": "",
"createDateTime": "2024-04-24T15:37:16",
"changeDateTime": "2024-04-24T15:45:28",
"favorite": true
},
{
"id": "523",
"name": "1"x1" Barcode w/Price",
"description": "",
"createDateTime": "2024-04-23T16:31:32",
"changeDateTime": "2024-04-24T15:11:56",
"favorite": true
},
{
"id": "524",
"name": "2"x1" Shelf Tag w/Price",
"description": "",
"createDateTime": "2024-04-24T14:52:33",
"changeDateTime": "2024-04-24T15:59:00",
"favorite": true
}
]
Currently, I have the value of the select component set to:
['{{azureTempListGet.data['0'].id}}',
'{{azureTempListGet.data['1'].id}}',
'{{azureTempListGet.data['2'].id}}']
and the label set to:
['{{azureTempListGet.data['0'].name}}',
'{{azureTempListGet.data['1'].name}}',
'{{azureTempListGet.data['2'].name}}']
I am sure there is code I can use to turn the API result into an array that can automatically create a new line for each ID and name based on how many results there are instead of having to manually type the same {{azureTempListGet.data['0'].name}} over and over and change the ['x'} each time.
Thank you for your time!