npm i global-countries
or
yarn add global-countries
In .js
files, the following codes will help
// Require the library
const globalCountries = require('global-countries')
// Get capital
const country = "IRAQ"
const iraqCapital = globalCountries.getCountryCapital(country)
console.log("Capital of IRAQ is", iraqCapital.toUpperCase())
// Get flag
const country = "IRAQ"
const iraqFlag = globalCountries.getCountryFlag(country)
// get call code
const country = "IRAQ"
const iraqCallCode = globalCountries.getCountryCallCode(country)
Click this link to see guidelines