Skip to content

Instantly share code, notes, and snippets.

@dceejay
Last active February 26, 2017 16:27
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 dceejay/3c17c7bf227d1a8952b7 to your computer and use it in GitHub Desktop.
Save dceejay/3c17c7bf227d1a8952b7 to your computer and use it in GitHub Desktop.
contrib-npm node example - UK Postcode geo lookup

Simple node-red-contrib-npm example

Uses the node-red-contrib-npm - https://www.npmjs.com/package/node-red-contrib-npm - node that can wrap simple npm modules automatically.

This example wraps the npm uk-postcode-node - https://www.npmjs.com/package/uk-postcodes-node - to create a node that can inject a UK postcode and retrieve the geolocation in an array of objects.

Note: You must install the node-red-contrib-npm before this example will work. Either via the Menu - palette manager or

cd ~/.node-red
npm i node-red-contrib-npm
[{"id":"692367fa.96dc98","type":"inject","z":"9e538f88.61ac7","name":"","topic":"","payload":"SO21 2JN","payloadType":"string","repeat":"","crontab":"","once":false,"x":215,"y":1763,"wires":[["9d6ba542.629458"]]},{"id":"9d6ba542.629458","type":"npm","z":"9e538f88.61ac7","name":"","func":"// NPM module exposed as variable, npm_module\nreturn npm_module(msg.payload);","npm_module":"uk-postcodes-node","module_style":"function","msg_payload":"callback_error","function_name":"getPostcode","x":399,"y":1763,"wires":[["34825370.cb7dac"]]},{"id":"34825370.cb7dac","type":"debug","z":"9e538f88.61ac7","name":"","active":true,"console":"false","complete":"false","x":611,"y":1763,"wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment