Array Responses

Hello all! Thanks for all of the guidance and help on my previous inquiries. I have gone from suboptimal JavaScript abilities to building packs that work. Thank you, Coda! I am however struggling mightily handling an Array of Objects as a response from a GET request. Let’s say we receive the below as a response -

{
    "things": [
        {
            "thingID": "11007",
            "thingname": "thing1",
        },
        {
            "thingID": "17216",
            "thingname": "thing2",
        },
        {
            "thingID": "16158",
            "thingname": "thing3",
        },
    ]
}

Is there a code example that shows how to handle something like this? I have gotten pretty decent when my formula returns one object but this is a new frontier! I am guessing my best option is to use resultType: coda.ValueType.Array as the formula result and then define those items by my object schema? I would love to “drill down” into array but I must be missing something obvious.

Hi @Thomas_Baucom - Glad to hear that Pack building is starting to click! If you wanted to return all of that data, they yes, you’d be looking at returning an Array of object schemas. This is briefly discussed in this section of the documentation:

Once you have lists of complex objects you should also consider if a sync table would make sense. You could include both a formula and a sync table for the same information, as each has it’s pros and cons. For example, the Google Calendar Pack includes both an “Events” sync table and an “Events” formula.

1 Like

@Eric_Koleda Thank you (per always) for pointing me in the right direction!