Help on listing the "Get" Data


I want to get the details of active servers and send it via email. My get Data is showing lot of details and some times only one server is active and sometimes 100 servers will be active. In my send email node I am using the previous workflow data as expression which is like below.
{{$node[“Server info”].json[“servers”][0][“hostname”]}}

[0] is sending only the first server in the list and ignoring all others. Is there a way I can list all of them with single expression.

Hi @mahesh,

I recommend you adding a “Function” node and composing available servers with this snippet:

return [
json: {
  servers: $['Server info'].json['servers'].map(function(server) {
 return server.hostname;

You will be able to access to the “servers” property in the following nodes.

Hope this helps,

1 Like

Hi Miquel,

I have created the function with the snippet you shared after the ‘Server Info’ node. I am getting the below error.

ERROR: $ is not defined

ReferenceError: $ is not defined

You are right. It is my fault.

Replace $ by $node and it will work.

Thanks @Miquel_Colomer
It worked. I added a list to the return to fetch other details like server ip.

return [server.hostname, server.ip]

I am getting the data output like below.


Any way to put this in table?

I don’t have programming skill. Can you suggest if we need to learn Node.js to understand and write these functions in the future? or any other programming?

Yes. Just do this:

return $node['Server info'].json['servers'].map(function(server) {
 return {json: {server: server.hostname}};
}) ;

Let me know if works.

This is giving the same problem as I mentioned in the first post.

Hey @mahesh!

Welcome to the community :slightly_smiling_face:

Can you please share the exact response you get? A screenshot of the output will be helpful.

Ok. I get you.
What you need is generate a table output in html code to send it by email. Try this:

var content = "<tr>" + ($node['Server info'].json['servers'].map(function(server) {
 return "<td>" + server.hostname + "</td><td>" + server.ip + "</td>";
}).join("</tr><tr>")) + "</tr>";

return [
  json: {
    output: "<table><tr><th>Hostname</th><th>Ip</th></tr>" + content + "</table>"

I recommend you to read any Javascript tutorial like this

or check existing js snippets done by n8n team at

Hope this works.

1 Like

This is perfect @Miquel_Colomer. Thanks a lot !!

I will read on javascript and thanks for sharing the links.

1 Like

You are welcome.

Enjoy n8n!

1 Like