-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflight.js
30 lines (26 loc) · 939 Bytes
/
flight.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
/*
* This requires: restler
* To install, type 'npm install restler'
* Tested with node.js v0.6.14
*/
var util = require('util');
var restclient = require('restler');
var fxml_url = 'http://flightxml.flightaware.com/json/FlightXML2/';
var username = process.env.username;
var apiKey = process.env.apiKey;
restclient.get(fxml_url + 'Arrived', {
username: username,
password: apiKey,
query: {airport: 'KJFK', howMany: 10, filter: '', offset: 0}
}).on('success', function(result, response) {
util.puts('Aircraft en route to KIAH:');
//util.puts(util.inspect(result, true, null));
var flights = result.ArrivedResult.arrivals;
for (i in flights) {
var flight = flights[i];
//util.puts(util.inspect(flight));
util.puts(flight.ident + ' (' + flight.aircrafttype + ')\t' +
flight.originName + ' (' + flight.origin + ')');
}
console.log(result.ArrivedResult.arrivals);
});