UNPKG

node-red-contrib-powerbi

Version:

A PowerBI API interaction node-red module which allows to interact with PowerBI service.

29 lines (23 loc) 746 B
var request = require('request'); module.exports = function(RED) { function PowerBIDashboards(config) { RED.nodes.createNode(this,config); // Retrieve the connection node. this.connection = RED.nodes.getNode(config.connection); var node = this; node.on('input', function (msg) { request({ method:'GET', url: 'https://api.powerbi.com/v1.0/myorg/dashboards', headers: { 'Authorization': 'Bearer ' + node.connection.accesstoken }}, function (error, response, body) { msg.status = response.statusCode; msg.headers = response.headers; msg.payload = body; node.send(msg); }); }); } RED.nodes.registerType('powerbi-dashboards', PowerBIDashboards); }