Access multidimensional array - REST

I struggle to show only first instance of an array inside the array (Multidimensional?)

I iterate full array but I only need (in second layer array - “bids”) the first instance of it… I cannot wrap my head around it…

Ex:

"items": [
  {"key" : "value"
....
"bids": [
                {
                    "id": 23329757,
                    "bidder": 1,
                    "color": "#2CC9C9",
                    "amount": 600,
                    "your_bid": false,
                    "reserve_met": false,
                    "auto": false,
                    "timestamp": 1696418416
                },
                {
                    "id": 23329738,
                    "bidder": 2,
                    "color": "#C9C92C",
                    "amount": 550,
                    "your_bid": false,
                    "reserve_met": false,
                    "auto": false,
                    "timestamp": 1696418345
                }
]
},

I tried:
return ${value->get('bids')[0].amount}
This returns “object Object”…

If I use:
$value->get('bids') --key iterable
then
$iterable->get('amount')
I get the amounts but all instances of them obviously…

Everything else I figured out but this is killing me
Sorry for my bad English, I hope you understand the issue…

Hi @MixxMaster

Can you share your domain name so I can help you.

__

In this case, I suggest setting the key in REST API directly to access first item of bids,

get('bids')->index('0')

@MixxMaster

image

Thanx @dejan :
This is the domain: https://stadsauktionsundsvall.divhunt.art/

To further explain, I already set the Key to get('items') (which is the main array) to be able to iterate over the “layer 2 arrays” (bids, images etc.)

This is the actual GET request: https://auctionet.com/api/v2/items.json?company_id=48&per_page=6&order=end_asc_active

@MixxMaster

You can do something like this

You can also use Conditions to hide the paragraph if there is no bids available, I can help with that if needed.

1 Like

@MixxMaster

Like this

1 Like

@MixxMaster

You can duplicate the paragraph and put another content and reverse the Condition to EMPTY to show something else like text No bids yet or similar.

1 Like

@dejan - Lifesaver :slight_smile:

Thanx a lot :pray:t3:

1 Like