1.0.5 • Published 7 months ago

global-pocket v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Global-pocket

This is an npm package that provides utility functions for fetching and managing country data from the REST Countries API. The package supports fetching all countries, fetching a country by its ISO 3166-1 alpha-2 code, and fetching a country by its name. It is designed to be secure, efficient, and professional.

Features

  • Fetch all countries with caching to reduce redundant API calls.
  • Fetch a specific country by its ISO 3166-1 alpha-2 code.
  • Fetch a specific country by its name.
  • Structured error logging for debugging.
  • Validates and normalizes API responses to handle inconsistencies.
  • Utilizes environment variables for better configuration and security.

Installation

npm install global-pocket

Function Reference

Get all countries

  const countries = await getAllCountries();

Get Country

   const countryByCode = await getCountryByCode("IN");
ParameterTypeDescription
codestringRequired. code of country to fetch

Get Country

   const countryByName = await getCountryByName("INDIA");
ParameterTypeDescription
namestringRequired. name of country to fetch

Authors

linkedin

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago