This is a Javascript wrapper around API provided by Restcountries.
npm i restcountries-js
const restcountries = require('restcoutries-js')
restcountries().all()
.then(data => {
console.log(data)
})
import restcountries from 'restcoutries-js'
restcoutries().all().then(data => {
console.log(data)
})
<script src="/node_modules/restcountries-js/dist/restcountries.min.js"></script>
<script>
restcoutries().all().then(data => {
console.log(data)
})
</script>
You can use your own API server, but it will work only with clone of this. This wrapper uses https://restcountries.eu endpoint as default.
restcountries('http://my.path.to/api').all()
.then(data => {
console.log(data)
})
These methods full description availble here: https://github.com/apilayer/restcountries