Describe the issue/error/question
I have some json output and I’m trying to iterate on “childNodeIds” to construct HTML code that I can pass to the API. Ideally I’d like to have a line of this for each ID in “childNodeIds” and so it should look like:
<figure class="image image_resized" style="width:36.64%;"><img src="api/images/Uu5tIBz3IJsc/image.png"></figure>
<figure class="image image_resized" style="width:36.64%;"><img src="api/images/HUfo5NJjcJ15/image.png"></figure>
<figure class="image image_resized" style="width:36.64%;"><img src="api/images/5VfNZZXLRp49/image.png"></figure>
This is what I tried which works in regular javascript but I am getting Error: Code doesn’t return an object [item0]
var items = [{"results[0].childNoteIds":"Uu5tIBz3IJsc"},{"results[0].childNoteIds":"HUfo5NJjcJ15"},{"results[0].childNoteIds":"5VfNZZXLRp49"},{"results[0].childNoteIds":"9p6ESoZf18fU"}];
var temp = ""
for (let i = 0; i < items.length; i++) { temp += '<figure class="image image_resized" style="width:100%;"><img src="api/images/' + items[i]["results[0].childNoteIds"] + '/image.png"></figure>' }
console.log(temp);
return temp
What is the error message (if any)?
I’m struggling to understand how to select the childNodeIds to use it in a for loop.
Please share the workflow
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database you’re using (default: SQLite):
- Running n8n with the execution process [own(default), main]:
- Running n8n via [Docker, npm, n8n.cloud, desktop app]: