Howto building/concatenating 2 items

Hello

I would like to merge 2 items
I’m not a dev so sorry about asking this.
I tried reading and found a code to merge 2 arrays but not as i want to get in result.

I have a fixed url (a domain)
but a different landing pages (variable)

So I:
set my value call “myurl” (for my static domain value)
and get from my previous node the “values” (for my variable pages)
for my approach i have add this both value in a node called Set_url

image

the code use in the function node based on my reseach

var json1 = `{{$node["Set_url"].json["myurl"]}}`;
var json2 = `{{$node["Set_url"].json["values"]}}`;

jsonmycompleteurl = json1.concat(json2);

Describe the issue/error/question

I thought the code below could work with my simple concatenation item1+item2
but i have this error
ERROR: Cannot read properties of undefined (reading ‘every’) [Line 772]

What is the error message (if any)?

Please share the workflow

workflow

1 it’s a basic url (“https://domain/dynamicpage”)
2 i split the url according to the “/” sign
3 I extract with the if only “values” containing numbers because my dynamic pages always have numbers while my domain does not.
4 it’s the set that regroup the two values in the node called Set_url

Thank you for your help on this

Information on your n8n setup

  • n8n version: 0.182.0
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:own(default)
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]:desktop app

Hi @Thierry66

Not completely sure what you are trying to do.
You are looking for a merge node if you want to actually merge different items together.

But I suspect you don’t really need this. You seem to simply want to add 2 string together that exist in the same item. (or can be added because one is static)
Can you share an example of the workflow with some mock data, this makes it a lot easier for us to help you. :slight_smile:

Hi @BramKn

Yes it’s true for " I suspect you don’t really need this. You seem to simply want to add 2 string together that exist in the same item. (or can be added because one is static)"

sure i can share a sample I have updated the workflow chapter in the question with it.

Hi @Thierry66

Please put the workflow in a ‘preformatted text’ block

1 Like

@Thierry66
is this what you need:

@BramKn
It works when i’m copy/paste your flow.
If I understand you have merge/combined in the node set_url1 the values of both items.
with the code below

{{$node["Set Example Data1"].json["sun"]}}{{ $json["values"] }}

Therefore I can use the myurl item from set_url1

Thank you !

Merging is a bit of an odd word to use here. As merging is normally of multiple sets of items into one set of items.

What you are doing is string building/concatenating

And yes this can easily be done within an expression. In this case in the set node.

1 Like

Understood @BramKn

So i have rewrite the question by removing the “merge” to “uilding/concatenating”

And i can use my worflow with my dynmic url now.

1 Like