Function Node

Hi,
I am trying to run the following in Function Node. I am not sure why the Set Object is empty

const s = new Set()

s.add(1)

s.add(2)

s.add(4)

return [{"json":{"set":s}}]

This is what it returns

[
{
"set": {
}
}
]

Hey @Ak92, I think this is because a Set is not a JSON data type. You could, however, convert it into for example an Array if you like:

const s = new Set()

s.add(1)

s.add(2)

s.add(4)

return [{"json":{"set":Array.from(s)}}]

image

1 Like

it solved my issue. Thank you

1 Like