I’m getting an error when attempting to apply the example to my final project, but in the example I was able to replicate the reason for the error. The actual format of my data is:
return [
{
json: {
"allData": [{
"counter": 2,
"result": "Sample String 1"
},
{
"counter": 2,
"result": "Sample String 2"
}
]
}
}
]
And this is the example showing the error with the data being output in way my project outputs it:
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
150,
550
]
},
{
"parameters": {
"functionCode": "return [\n {\n json: {\n\t\"allData\": [{\n\t\t\t\"counter\": 2,\n\t\t\t\"result\": \"Sample String 1\"\n\t\t},\n\t\t{\n\t\t\t\"counter\": 2,\n\t\t\t\"result\": \"Sample String 2\"\n\t\t}\n\t]\n}\n }\n]\n"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
340,
550
],
"notesInFlow": true,
"notes": "Mockup data"
},
{
"parameters": {
"functionCode": "\nreturn [\n {\n json: {\n names: items[0].json[0].allData.map((e) => e.result).join(',')\n },\n }\n]"
},
"name": "Function1",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
550,
550
],
"notesInFlow": true,
"notes": "Map data"
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
},
"Function": {
"main": [
[
{
"node": "Function1",
"type": "main",
"index": 0
}
]
]
}
}
}