Closed ptesny closed 8 months ago
I searched for the IATA and ICAO you are using, and they correspond to the code of the Paris Charles de Gaulle Airport. The method should received the IATA and ICAO of an airline. See the example bellow:
const { FlightRadar24API } = require("flightradarapi");
const fs = require("fs");
const frApi = new FlightRadar24API();
async function run() {
const result = await frApi.getAirlineLogo("G3", "GLO"); // GOL Airline
const data = Buffer.from(result[0]);
const filename = "image." + result[1];
fs.writeFile(filename, data, (err) => {
if (err) {
console.error(err);
}
});
}
run();
Thank you @JeanExtreme002 for spotting this. Indeed, the code and ICAO must be those of an airline and not of an airport. All good.
PS.
I prefer to return the base64 encoded image in the payload.
Good to know the second element of the airlineLogo array is the image format, namely png
, jpg
, etc.
code = urlParams.has('code') ? urlParams.get('code') : 'AF';
icao = urlParams.has('icao') ? urlParams.get('icao') : 'AFR';
try {
const airlineLogo = await frApi.getAirlineLogo(code, icao);
const data = Buffer.from(airlineLogo[0]);
return 'data:image/' + airlineLogo[1] + ';base64,' + data.toString('base64');
Describe the bug getAirlineLogo does not work in nodejs, for instance