return Statement

In CustomJS, the JavaScript you write has to explicitly tell Make what value to send back. The only way to do that is with a return statement.

If you don’t include return, the code may run internally, but Make won’t receive any result, so the workflow won’t have any output to continue working with.

JavaScript Code Field
JavaScript Code Field
AspectWithout ReturnWith Return
Code
// Example (won't return a value to Make)
const fullName = `${input.name} ${input.lastname}`;
// No return statement below — Make receives nothing
// Example (returns a value to Make)
const fullName = `${input.name} ${input.lastname}`;
return fullName;
ResultMake receives no output. The next module has nothing to use, so the workflow may fail or produce empty values.Make receives the string (e.g., "John Doe"). This value can now be used in subsequent modules.

Return statement guidelines

Return early for error handling

Use early returns to stop execution when required input is missing or invalid. Returning immediately when something is wrong avoids running the rest of the code and makes debugging easier.

AspectWithout early returnWith early return
Code
// Incorrect: runs even with missing input
const processedEmail = input.email.toLowerCase();
return { processedEmail };
// Correct: return early if input is missing
if (!input.email) {
  return { error: "Email is required" };
}

const processedEmail = input.email.toLowerCase(); return { processedEmail };

ResultCode crashes if input.email is undefined. The workflow may fail with an error.Code stops gracefully when input.email is missing. Make receives a clear error message instead of breaking.

Return consistent data structures

Always return data in the same shape (e.g., object with predictable keys). This makes downstream modules easier to configure, since they know what to expect regardless of success or failure. Moreover, a predictable output format prevents “undefined property” errors and simplifies mapping in Make.

AspectInconsistentConsistent
Code
// Incorrect: returns different structures
if (input.success) {
  return input.data;
} else {
  return "Processing failed";
}
// Correct: always return the same shape
if (input.success) {
  return { 
    status: "success",
    data: input.data,
    message: "Processing completed"
  };
} else {
  return { 
    status: "error",
    data: null,
    message: "Processing failed"
  };
}
ResultDownstream modules can’t predict the format. This causes mapping errors or undefined values.Downstream modules always get a predictable object. This makes mapping and error handling reliable.

Await async results before returning

When using asynchronous code (like fetch, database calls, or API requests), await the result and then return it. If you forget await or don’t return the resolved value, Make will just get a pending Promise, not usable data.

AspectWithout awaitWith await
Code
// Incorrect: returns a Promise, not data
return fetch(input.url).then(res => res.json());
// Correct: resolve the Promise before returning
const response = await fetch(input.url);
const data = await response.json();

return { statusCode: response.status, data: data };

ResultMake receives a Promise instead of usable data. The next module cannot work with unresolved Promises.Make receives the actual data (JSON object with status and content). The next module can directly use this result.

Final return statement and inline functions

Since we wrap your JavaScript code with an async expression, we recommend always defining return statements and ending inline functions with a semicolon.

Input-Field

{ }

JS-Code-Field

function fullName(firstName, lastName){ return `${firstName} ${lastName}`};
return fullName("John", "Doe");

Output-Field

{ output: "John Doe" }



With this help you ensure that your code runs smoothly and efficiently, especially when working with complex javscript function calls in Make.com.

Increase your flexibility in data processing by retrieving the values of input fields directly via the JavaScript variable "input" or by creating JSON objects for complex scenarios, as described in our guide on the example page for
JSON Parameter

Make Custom JavaScript UUID Example
Make Custom JavaScript UUID Example