n8n LabBeginner
Access the First Item of an Array in n8n
Your API request returned a list of line items in an order. In JavaScript and n8n, arrays start at index 0. Extract the name of the first item.
Live Execution Simulator
Idle
π₯
Incoming Data
βοΈ
n8n Node
π―
Next Step
> Ready. Type your expression below and click "Check Answer" to run the node.
Incoming Payload / Data:
{
"items": [
{ "name": "Pro Subscription", "price": 49 },
{ "name": "Setup Fee", "price": 99 }
]
}
$json.
βοΈ Your expression is executed against test data β any correct solution passes. +10 XP
β Solution & explanation
$json.items[0].name
Output: Pro Subscription
n8n expressions are JavaScript, so arrays are 0-based:
items[0] is the first object, and .name reads its property. n8n also adds the helper .first() to arrays, which reads more clearly.π‘ Pro tip: Coming from Make? Remember the index shift: Make's get(items; 1) equals n8n's items[0].
Also accepted: items.first().name