I would like to create an app variable that is a list of objects that is taken from a data variable REST Api.
I’m able to easily fill the data variable using the GET RECORD call, but I’m having trouble figuring out how to properly create a new variable that is a list of objects populated by the data that is pulled from the REST Api.
Additionally, the REST Api list is a “list of objects with 12 properties” but I would like the app variable to be a “list of objects with 5 variables”. I.e., I would like to select specific properties from the REST Api objects and use those as the properties for the app variable.
Any help would be greatly appreciated.
Create a variable of type “any value”
Set the value of this variable to the output of your http request.
Its is better to select fields returned by your rest api in the backend.
thanks for your advice. I think that would mainly work if there was only one variable.
I’m mainly trying to create a new variable as a list of objects from the schema returned from my rest API. The biggest issue I’m having is that the rest API schema is a list of objects with 12 properties, but I’d like to create an app variable as a list of objects with only 5 properties. Because I’m only using 5 properties, when I try to bind the schema from the rest API to the new app variable, it says it’s not compatible.
Hi there,
Use the MAP formula. This was described in an older post somewhere, I cannot find right now, but I had a similar issue.
When you try to bind your data variable and the page variable use the “Formula” binding type.
Then write something like this:
MAP(data.customers_all, {label: item.name, value: item.id})
In the case above I have a customers_all data collection coming from the Firebase Storage. It is an object with 12 properties but in my page variable I had an object with 2 properties.
In the code above the
- MAP formula selects the data resource
- we specify the properties of the page variable as “label” and “value”, you can have them as your choice for your variable
- the “item” is a reference to the chosen data variable
- after the item. you can specify the properties that you need from your data variable.
As a suggestion I placed this “set page variable” flow function after my “Data ‘customers_all’ changed” event but I think it can be placed right after “page mounted” event as well.
Good luck 
1 Like
Thank you, thank you!
I had given the MAP function a try before but couldn’t figure out why it wasn’t working. Your suggestion to place the “set page variable” flow function after my “Data ‘customers_all’ changed” event did the trick.
2 Likes
If it is a “list of object with 5 properties”, then how can I repeat those repeated object from a particular list in the firestore document. Detailed problem explanation HERE with screenshots.