Return Response Types

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.

Available Response Types

1. Object (Most Common)

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.

2. Array

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.

3. String/Text

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.

4. Number

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.

5. Boolean

Returns true or false.

const isEligible = input.age >= 18 && input.hasAccount;
return isEligible;

Use Case: For conditional logic or validation results.

6. Binary Data

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.

Setting Response Types in Make.com

In the Make.com interface, you can specify the expected response type:

  1. Auto-detect: Make.com automatically determines the type based on your return value
  2. Text: Forces the output to be treated as text
  3. Binary: For file data, images, PDFs, etc.
  4. JSON: For complex objects and arrays

Best Practices by Response Type

Object Returns

// 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()
};

Array Returns

// 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 }
];

Error Handling with Response Types

// 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
  };
}

Working with Make.com Collections

When your JavaScript returns an array, Make.com can process it as a collection:

Input Processing

// 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;

Bundle vs Individual Items

// 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

Advanced Response Patterns

Conditional Response Types

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;
}

Nested Object Structures

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)
    }
  }
};

Common Response Type Issues

1. Undefined Returns

// 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" };
}

2. Mixed Return Types

// 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() };
}

3. Large Data Returns

// 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.