Getting data from nested JSON using function node

The data I want to extract is the offerName and the offerLink

The problem is when using function node to extract these values
n8n returns with an error
ERROR: Cannot read properties of undefined (reading ‘data’)

What should I do to extract these values?

Hi @aero, when using the Function node you would need to keep the n8n data structure in mind. So the JSON data of your first item would be under items[0]

However, if the data under nodes is all you want, you might want to take a look at the Item Lists node instead. It would allow you to split out data by giving it a field name (like in your example), so you wouldn’t have to write JavaScript yourself.

1 Like

Thanks for the fast reply. It solved my problem👌

1 Like