I'm trying to get the number of objects from a query but am failing to get the syntax correct.
As you can see it sees 2 Objects
And even the UI tells me there's 2 keys in the parent object, but I can't seem to get this value into the query. I've tried the obvious .length etc but can't get it.
This is to dynamically drive the number of rows in a listView.
in the query you can use a transformer to format what is returned to be an array
Then you can use query1.data.Item.sites.length
Hmm that didn't seem to work. When I run the query without the transformer I get this returned
But when I add the transformer I get nothing returned
Is it because I'm doing a
If you're looking to grab the number of Objects from "Item.sites", which is expected to evaluate to 2, then you can use the Object.keys() method which will return an array of all your keys, then tag on the .length method which will tell you how many keys you have.
This would look like:
Hope this helps!