restcountries-js
v0.0.3
Published
restcountries api wrapper for javascript
Downloads
4
Readme
Restcountries-js
This is a Javascript wrapper around API provided by Restcountries.
Installation
npm i restcountries-js
Example in Node.js
const restcountries = require('restcoutries-js')
restcountries().all()
.then(data => {
console.log(data)
})
ES6 import
import restcountries from 'restcoutries-js'
restcoutries().all().then(data => {
console.log(data)
})
Webrowser
<script src="/node_modules/restcountries-js/dist/restcountries.min.js"></script>
<script>
restcoutries().all().then(data => {
console.log(data)
})
</script>
restcountries-js API
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(baseUrl)
restcountries('http://my.path.to/api').all()
.then(data => {
console.log(data)
})
restcountries method aliases
restcountries.all([extra])
restcountries.name(name[, fullText[, extra]])
restcountries.code(code[, extra])
restcountries.codes(codes[, extra])
restcountries.currency(currency[, extra])
restcountries.capital(capital[, extra])
restcountries.callingCode(callingCode[, extra])
restcountries.region(region[, extra])
restcountries.regionalBloc(regionalBloc[, extra])
These methods full description availble here: https://github.com/apilayer/restcountries