1 | "use strict";
|
2 |
|
3 | var http = require('http'),
|
4 | nextMeeting;
|
5 |
|
6 | var options = {
|
7 | hostname: 'www.jaxnode.com',
|
8 | port: 80,
|
9 | path: '/api',
|
10 | method: 'GET',
|
11 | headers: {
|
12 | 'Content-Type': 'application/x-www-form-urlencoded'
|
13 | }
|
14 | };
|
15 |
|
16 | var JnnData = function() {};
|
17 |
|
18 | JnnData.prototype.getNextMeeting = function(cb) {
|
19 | var req = http.request(options, function (response) {
|
20 | var result = '';
|
21 | response.setEncoding('utf8');
|
22 | response.on('data', function (chunk) {
|
23 |
|
24 | result += chunk;
|
25 | });
|
26 | response.on('end', function() {
|
27 | nextMeeting = JSON.parse(result);
|
28 | cb(nextMeeting);
|
29 | });
|
30 | });
|
31 | req.end();
|
32 | req.on('error', function(err) {
|
33 | console.log(err);
|
34 | cb(err);
|
35 | });
|
36 | };
|
37 |
|
38 | module.exports = new JnnData(); |
\ | No newline at end of file |