Allen AWF
Allen AWF

Reputation: 11

Issue with Zapier Code - Simple if else statement

I have looked over this countless times and yet I get the error "You must return a single object or array of objects.

if (inputData.score === '0') {
  output = 'Passed';
} else {
  output = 'Failed';
}

return output;

Not sure what I am doing wrong?

Upvotes: 0

Views: 475

Answers (1)

xavdid
xavdid

Reputation: 5262

David here, from the Zapier Platform team.

In your code, you're returning a string, not a javascript object ({}) or array of objects ([{}, {}]).

change your code to the following:

if (inputData.score === '0') {
  output = 'Passed';
} else {
  output = 'Failed';
}

return {result: output};

Upvotes: 1

Related Questions