SOMEONE HELP ME - How do I fix this code

Someone help me, I don’t know what else to do.

What code do I use to pull an image in the Code2 line.

I asked this question to chatgpt, and he provided me with this example code:

let article = ""; 
let imageUrl = ""; 

for (const item of $input.all()) {
  article += item.json.blogContent;
  article += "<br><br>";
  article += item.json.faq;
  article += "<br><br>";

  imageUrl = item.json.source_url;

const output = {
  "article": article,
  "url_imagem": imageUrl

return [output];

Make sure to add quotes:

article += '<img src"source_url">'


article += "<img src\"source_url\">"

Yeah, unfortunately no one will be able to help me with this! I do not know what else to do.

Hi @Edgard_Neto - sorry for the frustration here! Would you be able to share your workflow with us by copying the nodes and pasting the code here between two sets of three backticks (```) so we can debug this flow further with you?

@Edgard_Neto Hmm, that’s strange - can you follow this guide and see if you can export the workflow? Export and import | n8n Docs

Either one of those methods will work, as what we need is the JSON content :slight_smile:

@EmeraldHerald Sorry, I had to paste like this, it’s not working the other way.

Hi @Edgard_Neto - no problem, I can take a look into this, and depending on how it goes I may need a bit of help from the wider team on Monday, as I’m the only one in today on the support team :slight_smile:

Just as a heads up - your post contained some credentials, I’ve gone ahead and edited those out for you :+1:


OK thanks! if you need it in file format let me know, I’ll upload it to google drive and send it to you.

Hi @Edgard_Neto - taking a look at this with my teammate @MutedJam together, neither of us are too sure what you’re trying to do with this workflow. Unfortunately you’ve provided an example we cannot run as it requires external connections and it seems to also pull data from other nodes that do not exist.

Can you please show us some sample JSON data that would be fed into the Code node so we can look at your code with a runnable example? Otherwise we won’t be able to help here.


@EmeraldHerald @MutedJam

Hi, I will send the images of the codes, and I will try to send the flow below.

Image 1:

Image 2:

Image 3:


let article = “”;
let imageUrls = [];

for (const item of $input.all()) {
article += item.json.faq;
article += “


article += <img src="${item.json.image1}">;



const output = {
“article”: article,
“url_imagem”: imageUrls

return [output];

Hi @Edgard_Neto - I’m not able to run that example you provided in the Google Drive link as it still requires some credentials that we wouldn’t have to run, but I think your images may have highlighted the problem.

Instead of item.json.image1 on lines 8 and 10 in your code node as in your third screenshot, can you try $("Set6").first().json.image1 ? I think that should fix this up :thinking:

Hey @Edgard_Neto,

This looks very similar to other issues you have had in the past, Does the Set3 node output an image1 or is this data from a previous node that you want to use?


Hi Jon, I posted several images above, the Set3 node is related to the article, it has no connection with the image.

Only the no Set6 creates the connection with the image.


Hey @Edgard_Neto,

You did post the images but if you remember from the other issues you can only use item.json.x with data that is in the node directly before the code node and if you wanted to use the image and the output of Set3 you would need to use a merge node linking Set6 and Set3 so that all of the data is available.

1 Like


Thanks Jon, I changed the layout here and put it straight in, and it worked.

Thank you very much.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.