forked from hunkim/Wit-Facebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
46 lines (35 loc) · 1.02 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
function call(call, callback, context, cb) {
var http = require('http');
var options = {
host: 'bobbejaanbot.webhosting.be',
port: 80,
path: call,
method: 'GET'
};
http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (data) {
// Return data to callback function
callback(data, context, cb);
});
}).end();
}
function getForecast(data, callback, context, cb) {
var http = require('http');
var options = {
host: 'api.openweathermap.org',
port: 80,
path: '/data/2.5/weather?q=' + data + '&APPID=c0831363cb2c8d6377869d42384308fe',
method: 'GET'
};
http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (data) {
// Return data to callback function
callback(data, context, cb);
});
}).end();
}
module.exports.call = call;
module.exports.getForecast = getForecast;