Searching and filtering an API response with multiple arrays

Hi there,

I am trying to build a flight search app using FlightApi.io. FlightApi.io’s API response contains multiple arrays.

One array is “legs”, which contains numerical “IDs” for origin airports, destination airports, and carriers.

Then there is a “places” array which contains those “IDs” matched with Airport Codes and so on.

Example:

"legs": [
        {
            "id": "16216-2404021419--32385-1-12387-2404030005",
            "origin_place_id": 16216,
            "destination_place_id": 12387,
            "departure": "2024-04-02T14:19:00",
            "arrival": "2024-04-03T00:05:00",
            "segment_ids": [
                "16216-9596-2404021419-2404022148--32385",
                "9596-12387-2404022225-2404030005--32385"
            ],
            "duration": 406,
            "stop_count": 1,
            "marketing_carrier_ids": [
                -32385
            ],

The origin_place_id and destination_place_id are further below in the API response in the PLACES array. Each item within the places array will have the numerical ID and the actual airport code as key-value pairs.

Is there some way to pull the “legs” array and display the airport code from the “places” array in a single API call? Or would I have to do two calls, storing the data first, and filtering next?

You don’t need to do two API call for that, but you may need to do the filtering twice. You could use a state to store the API data and use :filtered and advance probably to filter what you need. Not sure to totally understand how you want to display data and we don’t see the full payload so it’s a little bit hard to provide a complete answer. But for sure, you don’t need to do two api call.