Socket
Socket
Sign inDemoInstall

restcountries-js

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    restcountries-js

restcountries api wrapper for javascript


Version published
Weekly downloads
3
Maintainers
1
Install size
423 kB
Created
Weekly downloads
 

Readme

Source

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

Contact

Telegram or by email

Keywords

FAQs

Last updated on 18 Dec 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc