Skip to content

Instantly share code, notes, and snippets.

@chromecide
Last active November 15, 2015 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chromecide/b8baf6ff25bea4a16124 to your computer and use it in GitHub Desktop.
Save chromecide/b8baf6ff25bea4a16124 to your computer and use it in GitHub Desktop.
Example: Using array-iterate

A simple example showing the basic usage of the array-iterate node from node-red-contrib-primitives

[{"id":"632329db.9cdcd8","type":"inject","z":"39731b9a.c68ce4","name":"Start Array Examples","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":152,"y":208,"wires":[["3ad86a65.c52796"]]},{"id":"3ad86a65.c52796","type":"function","z":"39731b9a.c68ce4","name":"CreateArrayPayload","func":"msg.payload = [\n {\n id:1,\n name: \"Item 1\"\n },\n {\n id:2,\n name: \"Item 2\"\n }\n];\nreturn msg;","outputs":1,"noerr":0,"x":382,"y":208,"wires":[["74168b09.8be974"]]},{"id":"74168b09.8be974","type":"array-iterate","z":"39731b9a.c68ce4","name":"ProcessNextItem","x":640,"y":208,"wires":[["84670aab.7b98f8"],["51d6becb.ae294"]]},{"id":"f5a452b5.0a5bb","type":"debug","z":"39731b9a.c68ce4","name":"","active":true,"console":"false","complete":"payload","x":1047,"y":190,"wires":[]},{"id":"84670aab.7b98f8","type":"template","z":"39731b9a.c68ce4","name":"Format ID and Name","field":"payload","format":"handlebars","template":"{{payload.id}} - {{payload.name}}","x":663,"y":62,"wires":[["f5a452b5.0a5bb","74168b09.8be974"]]},{"id":"51d6becb.ae294","type":"template","z":"39731b9a.c68ce4","name":"All Items Complete","field":"payload","format":"handlebars","template":"All Items have been processed.","x":650,"y":296,"wires":[["f5a452b5.0a5bb"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment