Javascript gather results of function


#1

Hello everybody. I’m actually working on a Reactjs application working with FlightXML (so I’m using Javascript), and I just can’t gather information into the code.

Here’s an example: I try to gather informations on flights that arrive at DXB to use it later:

var myTAB = {}

client.methods.airportBoards(airportBoardsArgs,
function (data, response) {
  for (var i = 0; i < data.AirportBoardsResult.departures.num_flights; i++) {
    let myFlight = data.AirportBoardsResult.departures.flights[i]
    var utcSeconds = myFlight.estimated_departure_time.epoch;
    var d = new Date(0)
    d.setUTCSeconds(utcSeconds);
    myTAB['flight' + i] = {
      id: myFlight.ident,
      airline: myFlight.airline,
    }
  }
  console.log(myTAB.flight0);
})
console.log(myTAB.flight0);

The first console.log give me the right object with 15 objects inside but the second one is undefined. What’s happends and how to fix it ? (I’m in Free mode, no pricing)