UNPKG

node-red-contrib-nanoleaf

Version:

[![platform](https://img.shields.io/badge/platform-Node--RED-red?logo=nodered)](https://nodered.org) [![Min Node Version](https://img.shields.io/node/v/node-red-contrib-nanoleaf.svg)](https://nodejs.org/en/) [![GitHub version](https://img.shields.io/githu

23 lines (20 loc) 733 B
module.exports = function (RED) { 'use strict' const axios = require('axios') function NewAccessToken(config) { RED.nodes.createNode(this, config) var node = this this.on('input', function (msg) { axios.post(`http://${config.host}:${config.port}${config.query}`) .then(r => { msg.payload = r.data.auth_token node.status({ text: `AccessToken: '${msg.payload}'` }) node.send(msg) }) .catch((err) => node.error(err.message, err)) }) } RED.nodes.registerType('new-access-token', NewAccessToken) }