how to use filer(flight xml nodejs)


#1

Hi

I am using the trial version of flight.xml as (nodejs).

However, we could not see much data with the code in the sample.

It’s my nodejs code

var util = require(‘util’);
var restclient = require(‘restler’);

var fxml_url = ‘http://flightxml.flightaware.com/json/FlightXML2/’;
var username = ‘’;
var apiKey = ‘’;

restclient.get(fxml_url + ‘MetarEx’, {
username: username,
password: apiKey,
query: {airport: ‘KAUS’, howMany: 1}
}).on(‘success’, function(result, response) {
// util.puts(util.inspect(result, true, null));
var entry = result.MetarExResult.metar[0];
//util.puts('The temperature at ’ + entry.airport + ’ is ’ + entry.temp_air + ‘C’);
console.log('The temperature at ’ + entry.airport + ’ is ’ + entry.temp_air + ‘C’);
});

restclient.get(fxml_url + ‘Enroute’, {
username: username,
password: apiKey,
query: {airport: ‘ICN’, howMany: 100, filter: ‘’, offset: 0}
}).on(‘success’, function(result, response) {
//util.puts(‘Aircraft en route to ICN:’);
console.log(‘Aircraft en route to ICN:’);
//util.puts(util.inspect(result, true, null));
var flights = result.EnrouteResult.enroute;
for (i in flights) {
var flight = flights*;
//util.puts(util.inspect(flight));
//util.puts(flight.ident + ’ (’ + flight.aircrafttype + ‘) ’ +
// flight.originName + ’ (’ + flight.origin + ‘)’);
console.log(flight.ident + ’ (’ + flight.aircrafttype + ‘) ’ +
flight.originName + ’ (’ + flight.origin + ‘)’);
}
});

it’s my result data

The temperature at KAUS is 26C
Aircraft en route to ICN:
ESR542 (B738) 노이 바이 국제공항 (VVNB)
JNA104 (B738) 옌타이 라이산 국제공항 (ZSYT)
CDG4087 (B738) 칭다오 류팅 국제공항 (ZSQD)
JJA1401 (737) 후쿠오카 공항 (RJFF)
JNA82 (B738) 타이완 타오위안 국제공항 (RCTP)
KAL930 (A333) 풀코보 공항 (ULLI)
MM5 (A320) 간사이 국제공항 (RJBB)
JJA1101 (737) 나리타 국제공항 (RJAA)
UAL893 (B744) 샌프란시스코 국제공항 (KSFO)
CSZ9033 (B738) 선전 바오안 국제공항 (ZGSZ)
KAL724 (B77W) 간사이 국제공항 (RJBB)
CES5061 (A320) 상하이 푸둥 국제공항 (ZSPD)
AAR318 (A321) 칭다오 류팅 국제공항 (ZSQD)
ESR882 (B738) 타이완 타오위안 국제공항 (RCTP)
CDG4081 (B738) 칭다오 류팅 국제공항 (ZSQD)

How do I edit or add data to see the data I want?

I want to see data such as departure airport, arrival airport, departure date, departure time, arrival date, arrival time.

Does the trial user have a lot of data separately?*


#2

In the sample code we just print out some of the data available in the flight array. To see all the fields available you could modify your code as follows:



for (i in flights) {
var flight = flights*;
console.dir(flight);
}
});