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":[]}]

Flow Info

Created 9 years ago
Updated 7 years, 9 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • inject (x1)
Other

Tags

  • npm
  • postcode
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option