Turn an array into an HTML unordered list <ul>

Hey there. I’m trying to transform an array of strings into an HTML unordered list. Essentially I have this code:

let myValues = [];

for (item of items) {
  myValues.push($node["GetRows"].json["Content"].split('?'));
}


return myValues.map(e => {
  return {
    json: {
      values: e
    }
  };
});

which takes a string and splits it into an array using a delimiter. The output of the Function node looks like this:


[
{
"values": [
"One",
"Two",
"Three"
]
}
] 

I want to take each of those values (one, two three) and wrap them in

  • so I can merge them into an html document. My JS is pretty much non-existant and I keep running into problems.

    Any help?

  • Hey @pepeday, welcome to the community :tada:

    I’ve done something similar in the past, have a look at the example workflow shared here:

    If you take a look at the last node Build Email, you can see how I am looping through the items array to build an HTML document consisting of a few div containers (which you can simply replace with list items as needed). To loop only through the values field of a single item, you could replace for (item of items) with something like for (value of items[0].json.values).

    Hope this helps! Let me know if you run into any trouble with this :slight_smile:

    1 Like

    That did the trick! Thanks a bunch! I had no idea how to correctly form the return value but I’m now using that as a template and it works like a charm.
    I’ve setup my workflow so that I can send my automated emails in a custom html template. Thank you!

    1 Like