Minor changes to structure
This commit is contained in:
@@ -17,7 +17,7 @@ export class Flight {
|
||||
}
|
||||
summary() {
|
||||
const s = [];
|
||||
if (this.departureAirport?.iata) s.push(this.departureAirport.iata);
|
||||
if (this.departureAirport?.iata) s.push(this.departureAirport.iata);
|
||||
if (this.arrivalAirport?.iata) s.push(this.arrivalAirport.iata);
|
||||
const route = s.length ? s.join(' → ') : 'Flight';
|
||||
const co2 = this.emissions?.co2_total ?? this.co2 ?? null;
|
||||
@@ -77,9 +77,9 @@ export class Calco2latoClient {
|
||||
async searchAirports(q, limit = 20, offset = 1) {
|
||||
const data = await this._fetchJSON({
|
||||
method: 'GET',
|
||||
query: { endpoint: 'airports.search', q, limit, offset }
|
||||
query: { endpoint: 'airports.search', iata: q, per_page: limit, page: offset }
|
||||
});
|
||||
const items = Array.isArray(data?.results) ? data.results : (Array.isArray(data) ? data : []);
|
||||
const items = Array.isArray(data?.results) ? data.results : (Array.isArray(data) ? data : []);
|
||||
return items.map(a => new Airport(a));
|
||||
}
|
||||
|
||||
@@ -94,6 +94,6 @@ export class Calco2latoClient {
|
||||
method: 'POST',
|
||||
body: { endpoint: 'flights.estimate', params }
|
||||
});
|
||||
return new Flight(data);
|
||||
return new Flight(data.flights[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user