Conditional not doing it's job, based on add-on data

Options

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

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Answer ✓
    Options

    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

  • Duncy Dunc
    Options

    Ahhhh. I added the .0. and it worked. I don't understand why from my lack of coding knowledge, but it works 😎 Thanks Michael! 🤜🔥🤛

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    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.

  • Duncy Dunc
    Options

    @Michael Udinski That makes sense. Thanks for taking the time to help me out. Tell the crew Dunc says hello 💪