Get country data from ISO 3166-1 alpha-2, which are two-letter country codes defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO).
npm install --save country-from-iso2
npm run test
// commonJS - Destructuring
const { getCountries, getCurrencySymbol } = require('country-from-iso2');
// ES6 - using webapack bundler
import { getCountries, getCurrencySymbol } from 'country-from-iso2';
Get a list of all countries from https://github.com/mledoze/countries
include
parameter is an optional. Contains a list of country's properties to be included in the final result. Check out JSON file at https://github.com/mledoze/countries/blob/master/countries.json for the list of all country's properties.
getCountries(); // retruns everything
getCountries(['cca2', 'name']); // gives you an array of countries with two properties only, named 'cca2' and 'name'.
Get a country data from 'ISO 3166-1 alpha-2'.
getCountry('us'); // case-insensitive
Get a country's currency symbol from currency.
getCurrencySymbol('usd') // case-insensitive and return `$`
Get a country's currency symbol from 'ISO 3166-1 alpha-2'.
getCurrencySymbolFromIso2('us') // case-insensitive and return `$`
MIT