NPM package to get the capital of the countries
node -v
node: >= v8.3
npm install --save central-cities
npm i central-cities
yarn add central-cities
const Countries = require('central-cities')
const countries = new Countries()
import Countries from 'central-cities'
const countries = new Countries()
const portugal = countries.byName('portugal')
/**
* Get all country data
[{
"country": "Portugal",
"city": "Lisboa",
"independence": "1143",
"location": "Southern Europe"
}]
*/
portugal.toJson()
// get capital
portugal.capital // Lisboa
import Countries from 'central-cities'
const countries = new Countries()
countries.locations() // return type: array of strings
const portugal = countries.byName('portugal') // return type: Countries class
portugal.capital // return type: string ("Lisboa")