Created
July 15, 2025 06:45
-
-
Save kholisrag/3afa2f11fe985d9ff41c67f8991b6e54 to your computer and use it in GitHub Desktop.
n8n Code node - Javascript to combine multiple items to 1 items after merging using Append
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script merges all incoming items into a single object. | |
const combinedObject = {}; | |
// Loop through each item that flows into this node. | |
for (const item of items) { | |
// Merge the properties of the current item's JSON into our single object. | |
// Object.assign() copies all properties from the source (item.json) | |
// to the target (combinedObject). | |
// If a key already exists, it will be overwritten by the last one found. | |
Object.assign(combinedObject, item.json); | |
} | |
// n8n expects an array of items as the output. | |
// We return an array containing just our single, combined object. | |
return [{ | |
json: combinedObject | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment