Zapier Function Returning Wrong Format Error with Conditional Logic

I keep getting an error message saying “You must return a single object or array of objects” when running my Zapier code step. I have checked my logic multiple times but can’t figure out what’s wrong.

if (inputData.result === '1') {
  status = 'Success';
} else {
  status = 'Failure';
}

return status;

The conditional statement seems correct to me. I’m checking if the input result equals ‘1’ and setting a status variable accordingly. Then I return that status. But Zapier keeps throwing this error about needing an object or array. What am I missing here? Any help would be appreciated.

had this same prob last week! zapier is picky about return formats. change your return line to return {result: status}; - it needs an object wrapper even for simple strings.

This happens because Zapier needs code steps to return objects, not just strings. When you return status by itself, Zapier can’t handle it properly. I hit this same issue on a client project while processing webhook data. Easy fix though - just wrap your variable in an object. Use return {status_result: status}; or whatever property name works for your setup. This gives Zapier the structure it expects so it can pass the data to your next steps. Now I just wrap everything in objects from the start - saves me the trouble later.

Zapier code steps require you to return an object instead of just a string. Your conditional logic appears to be correct, but you need to wrap your return statement in an object. Instead of return status;, you should use return {status: status}; which will create an object with a status property containing your string value. I encountered this same issue when I first started using Zapier and spent a lot of time trying to debug my logic, only to find it was a formatting issue. The error message is understandable once you know what Zapier expects, but it can be quite confusing initially.