When writing JavaScript in Make.com, it's crucial to understand the different types of data you can return and how Make.com handles each type. The return response type determines how your data flows to the next module in your scenario.
Returns a JavaScript object that becomes available as individual fields in subsequent modules.
return {
name: "John Doe",
email: "john@example.com",
age: 30,
isActive: true
};
Use Case: When you need to pass multiple related values to the next module.
Returns an array of items, which Make.com can iterate over or process as a collection.
return [
{ id: 1, name: "Product A", price: 29.99 },
{ id: 2, name: "Product B", price: 39.99 },
{ id: 3, name: "Product C", price: 19.99 }
];
Use Case: When processing lists of items or when you need to trigger subsequent modules for each array item.
Returns a simple text value.
const fullName = `${input.firstName} ${input.lastName}`;
return fullName;
Use Case: When you only need to pass a single text value to the next module.
Returns a numeric value.
const total = input.items.reduce((sum, item) => sum + item.price, 0);
return total;
Use Case: For calculations, counts, or any numeric operations.
Returns true or false.
const isEligible = input.age >= 18 && input.hasAccount;
return isEligible;
Use Case: For conditional logic or validation results.
Returns binary data such as files, images, or documents.
// Example: Converting base64 to binary
const buffer = Buffer.from(input.base64Data, 'base64');
return buffer;
Use Case: When working with file uploads, image processing, or PDF generation.
In the Make.com interface, you can specify the expected response type:
// Good: Consistent property names
return {
userId: input.id,
userEmail: input.email,
userStatus: "active",
lastLogin: new Date().toISOString()
};
// Avoid: Inconsistent or unclear property names
return {
id: input.id,
mail: input.email,
status: 1,
login: Date.now()
};
// Good: Consistent object structure in arrays
return input.orders.map(order => ({
orderId: order.id,
customerName: order.customer.name,
orderTotal: order.total,
orderDate: order.createdAt
}));
// Avoid: Mixed data types in arrays
return [
{ id: 1, name: "Order 1" },
"Order 2",
{ id: 3, total: 100 }
];
// Always return consistent types, even for errors
try {
const result = await processData(input);
return {
success: true,
data: result,
error: null
};
} catch (error) {
return {
success: false,
data: null,
error: error.message
};
}
When your JavaScript returns an array, Make.com can process it as a collection:
// If input is a Make.com collection, convert it first
const items = Array.isArray(input) ? input : [input];
const processedItems = items.map(item => ({
processedId: `proc_${item.id}`,
processedName: item.name.toUpperCase(),
processedAt: new Date().toISOString()
}));
return processedItems;
// Return as bundle (single output)
return {
items: processedItems,
totalCount: processedItems.length,
processedAt: new Date().toISOString()
};
// Return as individual items (multiple outputs)
return processedItems; // Each item becomes a separate bundle
if (input.returnType === 'summary') {
return {
totalItems: input.items.length,
totalValue: input.items.reduce((sum, item) => sum + item.value, 0)
};
} else if (input.returnType === 'details') {
return input.items.map(item => ({
...item,
processed: true,
processedAt: new Date().toISOString()
}));
} else {
return input.items;
}
return {
customer: {
id: input.customerId,
profile: {
name: input.customerName,
email: input.customerEmail,
preferences: {
newsletter: true,
notifications: false
}
}
},
order: {
id: input.orderId,
items: input.items.map(item => ({
productId: item.id,
quantity: item.qty,
price: item.price
})),
totals: {
subtotal: calculateSubtotal(input.items),
tax: calculateTax(input.items),
total: calculateTotal(input.items)
}
}
};
// Wrong: Function might return undefined
function processData(data) {
if (data.valid) {
return { processed: data };
}
// Missing return for invalid data
}
// Correct: Always return something
function processData(data) {
if (data.valid) {
return { success: true, processed: data };
}
return { success: false, error: "Invalid data" };
}
// Wrong: Inconsistent return types
if (input.format === 'json') {
return { data: input.data };
} else {
return input.data.toString(); // Different type!
}
// Correct: Consistent return structure
if (input.format === 'json') {
return { format: 'json', data: input.data };
} else {
return { format: 'string', data: input.data.toString() };
}
// Be mindful of data size limits
const largeDataset = input.records;
// If dataset is too large, consider pagination
if (largeDataset.length > 1000) {
return {
data: largeDataset.slice(0, 1000),
hasMore: true,
nextOffset: 1000,
total: largeDataset.length
};
} else {
return {
data: largeDataset,
hasMore: false,
total: largeDataset.length
};
}
Understanding and properly implementing response types ensures your Make.com scenarios work reliably and your data flows correctly between modules.