{"size": 928, "ext": "js", "max_stars_repo_path": "node_helper.js", "max_stars_repo_name": "htilburgs/MMM-MyDutchWeather", "max_stars_repo_stars_event_min_datetime": "2019-04-06T07:12:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-04T19:12:58.000Z", "max_issues_repo_path": "node_helper.js", "max_issues_repo_name": "htilburgs/MMM-MyDutchWeather", "max_issues_repo_issues_event_min_datetime": "2019-08-29T12:15:29.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-05T15:09:39.000Z", "max_forks_repo_path": "node_helper.js", "max_forks_repo_name": "htilburgs/MMM-MyDutchWeather", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 7, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 24.4210526316, "max_line_length": 86, "alphanum_fraction": 0.5646551724}
/*
//-------------------------------------------
MMM-MyDutchWeather
Copyright (C) 2019 - H. Tilburgs
MIT License
//-------------------------------------------
*/

const NodeHelper = require('node_helper');
const request = require('request');

module.exports = NodeHelper.create({

  start: function() {
          console.log("Starting node_helper for: " + this.name);
  },

  getMWB: function(url) {
	request({
	url: url,
	method: 'GET'
	}, 
	(error, response, body) => {
		if (!error && response.statusCode == 200) {
		var result = JSON.parse(body).liveweer['0'];			// JSON data path - object.liveweer.0
		console.log(response.statusCode + result);				// uncomment to see in terminal
		this.sendSocketNotification('MWB_RESULT', result);
		}
        });
    },

  socketNotificationReceived: function(notification, payload) {
            if (notification === 'GET_MWB') {
            this.getMWB(payload);
            }
  }
});
