raumstatus/node/ctdo-api.js

23 lines
569 B
JavaScript
Raw Normal View History

2018-04-19 18:17:45 +00:00
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var request = require('request');
var CTDOApi= function(url) {
var self = this;
this.poll = function() {
request({url: "https://" + url}, function(error, res, response) {
if (error) {
self.emit('failed', error)
} else {
var parsedResponse = JSON.parse(response);
self.emit('done', parsedResponse);
}
});
};
};
util.inherits(CTDOApi, EventEmitter);
module.exports = CTDOApi;