Hey there,
I’m getting “undefined” when trying to access the property of an Object in the API response when setting the text value of a label, if I don’t use a List component. If I use a List component, I cannot get the text to change at all. Either way, I cannot access the property value. Please can someone help?
So far I’ve watched the YT tutorials, read this: Can't get properties from list object and this JSON to List Help - #11 by Mark but without success as I’m not sure what I’m doing wrong.
Here’s how it looks:
This is the URL being called: https://jsonplaceholder.typicode.com/comments?id=1
And this is the response:
[
{
“postId”: 1,
“id”: 1,
“name”: “id labore ex et quam laborum”,
“email”: “Eliseo@gardner.biz”,
“body”: “laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium”
}
]
I know the URL works as I can set the text of the label to just be the raw response and this works every time. Screenshot of response in app and blocks if I just sent the label text to be the response
But…
When the blocks are like this, the text of the label becomes “undefined”
When the blocks are like this, the text of the label does not change
I’ve tried replacing the get property “email” with a string block and typing in ‘email’, changing the list number/counter to 0 and 2 (in case there is an index issue) and a few other variations but I do not know how to access the property of an object.
Please could you advise what I’ve done wrong and how I can debug this (to help myself) so that I can get the object property value and use lists correctly with the API call?
Thanks in advance
PS. Full disclosure, I did originally open a topic on this here WebAPI Cannot access property which was marked as resolved but this was down to the API itself not working. Now the API is definitely up, I still cannot get the code to work hence the new thread. Thanks