Skip to content

Latest commit

 

History

History
81 lines (55 loc) · 1.81 KB

README.md

File metadata and controls

81 lines (55 loc) · 1.81 KB

Airports - Node.js Usage Instructions

This document provides step-by-step instructions on how to use the airport-data-js library in a Node.js environment.

Table of Contents

  1. Setting Up
  2. Integrating the Library
  3. Fetching Data
  4. Error Handling
  5. Additional Notes

Setting Up

  1. Install NodeJS Ensure you have Node.js installed.

  2. Initialize a new Node.js project (if you haven't already):

    npm init -y
  3. Install the airport-data-js library:

    npm install airport-data-js

Integrating the Library

  1. Import the library in your Node.js script:

    const airports = require('airport-data-js');

Fetching Data

Use the available methods to fetch airport data:

  1. By IATA Code:

    const dataByIata = await airports.getAirportByIata('MAA');
    console.log(dataByIata);
  2. By ICAO Code:

    const dataByIcao = await airports.getAirportByIcao('VOMM');
    console.log(dataByIcao);
  3. By City Code:

    const dataByCity = await airports.getAirportByCityCode('NYC');
    console.log(dataByCity);

... and so on for other methods.

Error Handling

Each method returns a promise. Handle errors using try/catch:

try {
    const data = await airports.getAirportByIata('AAA');
    console.log(data);
} catch (error) {
    console.error('Failed to fetch data:', error.message);
}

Additional Notes

  • The library fetches data based on the provided codes. Ensure the codes are valid and in the expected format.
  • For any issues or further documentation, refer to the main README.md.