Conditional not doing it's job, based on add-on data
Hey I have a conditional not doing it's job, based on add-on data from a query. See the vid below and let me know if I'm doing something wrong. Thanks!
Here is a video I made showing what's going on: https://www.loom.com/share/9f86975c43fe4602b83905f372c4c6d4
Best Answer
-
Hey Chris - it looks like your add on is also an array. If your just expecting one value in the array, you may want to return it as a single item, otherwise you'd have to also loop through your _hunt array or use dot notation with the index like item_upcoming._hunt.0.published
Answers
-
Ahhhh. I added the .0. and it worked. I don't understand why from my lack of coding knowledge, but it works 😎 Thanks Michael! 🤜🔥🤛
-
Great to hear! This is because your add on is a list, as noted by the flat brackets []... Even though it's a list of 1, it is still a list. Indexes in lists (arrays) tell us the place in the list where something is. Indexes start at 0. So 0 is the first position, 1 is the second position, etc.
My point being, if you just are trying to return one item in your add on. You could change the return type from list to single and then you would not need to specify the index of 0 in your dot notion.
-
@Michael Udinski That makes sense. Thanks for taking the time to help me out. Tell the crew Dunc says hello 💪
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback