Hi can someone explain what im doing wrong?
In the images below you can see my function and the console log. “unit” is loaded correctly (one array of length 1), and all the properties are there. However when i try to access the properties they are “undefined”.
Hi!
As you mentioned, “unit” is an array. In this case, it’s an array with one object. To access this object, use: unit[0]._id.
unit[0]._id
I’m assuming that “unit” is a data source with cardinality “MANY,” indicating an array with potentially zero or more objects.
If the data source had cardinality “ONE,” it would be an object rather than an array, and your code would have worked.
Hope this helps!