-
Notifications
You must be signed in to change notification settings - Fork 0
/
flightPrice.js
25 lines (21 loc) · 897 Bytes
/
flightPrice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const axios = require('axios');
async function getFlightPrices(origin, destination) {
try {
const apiKey = 'HZv3LiIEdU5Yz2KAEIqF8mOPw1csMMAZ'; //myapikey
//urlofFlightprice
const url = `https://test.api.amadeus.com/v1/analytics/itinerary-price-metrics?originIataCode=DEL&destinationIataCode=JAI&departureDate=2021-03-21¤cyCode=INR&oneWay=true`;
const response = await axios.get(url);
const flightData = response.data;
// Process flight data and display prices
flightData.forEach((flight) => {
const price = flight.price;
console.log(`Flight from ${origin} to ${destination}: $${price}`);
});
} catch (error) {
console.error('Error retrieving flight prices:', error.message);
}
}
// Usage example
const originCity = 'New Delhi';
const destinationCity = 'Jaipur';
getFlightPrices(originCity, destinationCity);