country-list
Maps ISO 3166-1-alpha-2 codes to English country names and vice versa.
Uses data from http://data.okfn.org/data/country-list
Example
var countries = require('country-list')();
console.log(countries.getValue('IS'));
console.log(countries.getLabel('Iceland'));
Methods
Usage:
var countries = require('country-list')();
All input is case-insensitive.
getValue(code)
Expects a two-digit country code.
Returns the name for that country.
If not found, it returns undefined
.
getLabel(name)
Expects the English country name.
Returns the code for that country.
If not found, it returns undefined
.
getValues()
Returns an array of all country names.
getLabels()
Returns an array of all country codes.
getValueList()
Returns a key-value object of all countries using the name as key.
getLabelList()
Returns a key-value object of all countries using the code as key.
getData()
Returns an array of all country information, in the same format as it gets imported.
Use with
Install
npm install react-select-country-list
License
MIT