Hello there,
I have a problem getting to data in an array. A few minutes ago i could do {{ Products_ProductCollection.data.id}} without a problem, now i cant get to the property.
Hello there,
I have a problem getting to data in an array. A few minutes ago i could do {{ Products_ProductCollection.data.id}} without a problem, now i cant get to the property.
I used the following template Warehouse Inventory Management Mobile App | Retool. Even if i make a new app i still cant do the data.id
Hey @not_zero! Welcome to the community.
Because data
is an array, it doesn't have its own id
parameter. Instead, each element of the array will have an id
parameter. In order to access the id
of the first element, for example, you could write Products_ProductCollection.data[0].id
.
I hope that helps! Feel free to follow up here with more info about your particular use case if you need additional guidance.
Thanks for the warm welcome and a fast answer. I know i can do the array iteration but, i just dont get it why i could call it before but now i cant. What changed? Was it not an array before?
Also when doing the index iteration when i want to do it like
Products_ProductCollection.data[i].id
I get the i is not defined error.
The only reason it would have been possible previously is if data
was an object and not an array. Is it possible that the query itself changed?
Can you share a screenshot or code snippet of the iteration that you're currently doing? It would definitely help us to debug.
I was trying to send an email as query finished.
This is how i was doing it. I was playing with concat and foreach sentences because i wanted to get the format as a list for each product. Is it possible the query changed when trying this? Can i somehow change the data back to object? I tried changing the transform results on the query return formatDataAsArray(data)
or return formatDataAsObject(data)
. But i still cant get back to the original data.
Email query body before:
{{ Products_ProductCollection.data.url }}
Email query i have now: Now i get the data from the array with this option.
{{ Products_ProductCollection.data[i].url }}
PS: With {{ Products_ProductCollection.selectedItem.url }}
i can still do as i did before without a problem
Thanks for the update! I guess I'm still a little unclear about the structure of your app and what you're trying to accomplish.
Assuming Products_ProductCollection
has always been a Collection
component, there's no way its data
property should have ever returned anything other than an array. It's probably most important to know whether you want/need to work with an array of product data or an object with data about a single product. That would help clarify next steps!