import { fetch } from "https://esm.town/v/std/fetch";
export const checkRyanair = (async () => {
const BASE_URL = "https://services-api.ryanair.com/farfnd/3/";
const AIRPORT_FROM = "STN";
const AIRPORT_TO = "VIE";
const START_FROM = "2023-12-10";
const START_TO = "2023-12-24";
const END_FROM = "2024-01-01";
const END_TO = "2024-01-05";
const PRICE_LIMIT = "260";
const fetchUrl = `${BASE_URL}roundTripFares?` +
`&arrivalAirportIataCode=${AIRPORT_TO}` +
`&departureAirportIataCode=${AIRPORT_FROM}` +
`&outboundDepartureDateFrom=${START_FROM}` +
`&outboundDepartureDateTo=${START_TO}` +
`&inboundDepartureDateFrom=${END_FROM}` +
`&inboundDepartureDateTo=${END_TO}` +
`&priceValueTo=${PRICE_LIMIT}`;
const res = await fetch(fetchUrl);
const flights = await res.json();
console.log(flights?.total);
if (flights?.total > 0) {
console.log(flights.fares[0].outbound.departureDate);
console.log(flights.fares[0].inbound.departureDate);
}
console.log(flights);
})();