Replace multiple variables values with Function Node

This is actually less of an n8n related question, more a JavaScript-related one.

Anyway the solution is a loop:

let index = 0;
for (const data of $node["WooCommerce Trigger"].json["meta_data"]) {
  items[0].json[`url${index++}`] = data.value.replace(/^(?:https?:\/\/)?(?:www\.)?/i, "").split('/')[0];
}
return items;

Not sure if you skip on purpose the first value in “meta_data”, in my example I do not and iterate over all of them and so also start with url0.

Here the nodes:

2 Likes