Package Exports
- restcountries-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (restcountries-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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