Having some issues with .listProperties()
with the v4 API
This little bit of code is broken, and I have no idea how to fix it:
var thingProperties = await thingsList.get(itms,1)[0].listProperties();
I just get following error:
Having some issues with .listProperties()
with the v4 API
This little bit of code is broken, and I have no idea how to fix it:
var thingProperties = await thingsList.get(itms,1)[0].listProperties();
I just get following error:
Are you sure there’s an item at the itms
position?
Also, you shouldn’t have to await that at all, it’s not asynchronous
There are definitely things in the list - the code works perfectly on the v3 API, but upgrading breaks it with the exact same data.
I believe the await is required for the .get(), according to the upgrade docs.
If you want to keep all in one line:
(await thingsList.get(itms,1))[0]?.listProperties()
I think it’s just better to split it on multiple lines: await the item first, check that there is one and then list the properties.
Thanks @dorilama,
Your suggestion definitely helped, although the closed parenthesis looked like it needed to be moved to before the question mark:
(await thingsList.get(itms,1)[0])?.listProperties();
That hurdle is closed, but now I’m having issues with properties.itemlist.length
- this is always returning a null, even though I know with absolute certainty that there are items in the list.
Do you have any insights on this one?
Thanks
Simon
did you read the docs?
your modified expression will always return undefined
.
Thanks @dorilama,
I’m a complete noob when it comes to coding, so I have to hack my way though it, and the errors don’t always explain what’s going.
Even though the docs are somewhat helpful, they don’t help someone like me who is fumbing their whole way though.
Thanks to your help though, I have finally managed to get everything working.
Cheers
Simon