I’m putting a switch statement in a function node. Getting the error:
ERROR: executionData.every is not a function [Line 731]
The preceding node gets an order object, “source_name” from Shopify, “Shopify Trigger”, that looks fine. I think I’m referencing the source node correctly. Stumped!
let namingSeries = "";
switch ($node["Shopify Trigger"].json["source_name"]) {
case "pos":
namingSeries = "POS-";
break;
case "web":
namingSeries = "WEB-";
break;
default:
namingSeries = "eBay-";
}
return namingSeries;
The problem will be your return value which is a string. n8n does however expect an array following a specific structure (since a few versions it can also handle generic objects, but no primitives yet).
So if you rewrite your Function code to follow n8n’s data structure the error should disappear, for example like so:
Thanks, @MutedJam ! I read and re-read the docs, which are perfectly clear, but I didn’t register that important bit. Can’t wait to get back to it now, though I’m off to a client’s site.
Mike
I guess the next question would be: is it possible to make the error message more descriptive? Like check the result data structure and throw an exception with an informative message?