Giter VIP home page Giter VIP logo

country-state-picker's Introduction

Country State Picker

NPM package to get the list of countries and their states.

npm version

Installation

npm i country-state-picker --save

Usage

getCountries()

This function will return the array of all the countries.

Output

[
    {
        "name": "Afghanistan",
        "code": "af",
        "dial_code": "+93"
    },
    {
        "name": "Albania",
        "code": "al",
        "dial_code": "+355"
    },
    {
        "name": "Algeria",
        "code": "dz",
        "dial_code": "+213"
    },
    {
        "name": "Andorra",
        "code": "ad",
        "dial_code": "+376"
    }
  ...
]

getStates(<country_code>)

This function will return the array of all the states of a given country.

Example

To get the list of all the states of INDIA, the function call will look like:

let states = getStates('in');

console.log(states)

Output

[
    "Assam",
    "Goa",
    "Madhya Pradesh",
    "Manipur",
    "Meghalaya",
    "Mizoram",
    "National Capital Territory of Delhi",
    "Sikkim",
    "State of Andhra Pradesh",
    "State of Arunachal Pradesh",
    "State of Bihar",
    "State of Chhattisgarh",
    "State of Gujarat",
    "State of Haryana",
    "State of Himachal Pradesh",
    "State of Jammu and Kashmir",
    "State of Jharkhand",
    "State of Karnataka",
    "State of Kerala",
    "State of Maharashtra",
    "State of Nagaland",
    "State of Odisha",
    "State of Punjab",
    "State of Rajasthan",
    "State of Tamil Nad",
    "State of Uttarakhand",
    "Telangana",
    "Tripura",
    "Union Territory of Andaman and Nicobar Islands",
    "Union Territory of Chandigarh",
    "Union Territory of Dadra and Nagar Haveli",
    "Union Territory of Daman and Di",
    "Union Territory of Lakshadweep",
    "Union Territory of Puducherry",
    "Uttar Pradesh",
    "West Bengal"
]

getCountry(<country_name | country_code | dial_code>)

This function will return the country corresponding to the argument passed.

Example

To get the country having dial code "+91", the function call will look like:

let country = getCountry('+91');

console.log(country)

Output

{
    "name": "India",
    "code": "in",
    "dial_code": "+91"
}

country-state-picker's People

Contributors

anupkumarpanwar avatar miag0 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.