An API for getting info about countries
You may install this package with this command:
npm install all-countries --save
Once the package has been installed, it can be required inside your code with this line of JavaScript:
var allCountries = require('all-countries');
There are a number of members available. They are as follows:
Type: 'Variable'
Returns: Array
This returns all countries as an array of strings.
Example:
var allCountries = require('all-countries');
console.log(allCountries.all); // [ '...']
Type: 'Function'
Parameter: 'code'
Returns: String
This returns country name as a string based on the passed in ISO2 country code.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCountryByCode('US')); // United States
Type: 'Function'
Parameter: 'capital'
Returns: String
This returns country name as a string based on the passed in country capital.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCountryByCapital('Washington')); // United States
Type: 'Function'
Parameter: 'phoneCode'
Returns: String
This returns country name as a string based on the passed in country phone code.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCountryByPhoneCode('1')); // United States
Type: 'Function'
Returns: Array
This returns all ISO2 country codes as an array of strings.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCountryCodes); // [ '...']
Type: 'Function'
Parameter: 'phoneCode'
Returns: String
This returns country code as a string based on the passed in country name.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCountryCodeByCountryName('United States')); // US
Type: 'Variable'
Returns: Array
This returns all country capitals as an array of strings.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCapitals); // [ '...']
Type: 'Function'
Parameter: 'code'
Returns: String
This returns a country capital as a string based on the passed in ISO2 country code.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCapitalByCountryCode('US')); // Washington
Type: 'Variable'
Returns: Array
This returns all country currency codes as an array of strings.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCurrencies); // [ '...']
Type: 'Function'
Parameter: 'code'
Returns: String
This returns a country currency code as a string based on the passed in ISO2 country code.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getCurrencyByCountryCode('US')); // USD
Type: 'Variable'
Returns: Array
This returns all phone codes as an array of strings.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getPhoneCodes); // [ '...']
Type: 'Function'
Parameter: 'code'
Returns: String
This returns a country phone code as a string based on the passed in ISO2 country code.
Example:
var allCountries = require('all-countries');
console.log(allCountries.getPhoneCodeByCountryCode('US')); // 1