JSPM

country-state-city-plus

1.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q37208F
  • License GPL-3.0

Library for fetching Country, its States and Cities forked from country-state-city

Package Exports

  • country-state-city-plus

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 (country-state-city-plus) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

country-state-city

Basic library for Country, State and City forked from

https://github.com/harpreetkhalsagtbit/country-state-city

Data taken from:

https://github.com/hiiamrohit/Countries-States-Cities-database

Install

npm i country-state-city-plus

Usage

Latest Release : v1.0.0 (First Major Version Release - Not backward compatible)

  • ES6 Module usage

    import csc from 'country-state-city'
    
    // Import Interfaces`
    import { ICountry, IState, ICity } from 'country-state-city'
  • AMD Module usage

    let csc = require('country-state-city').default

Docs

visit for the functions

https://github.com/harpreetkhalsagtbit/country-state-city/#readme

getCountryByName(name)

It accepts a valid CountryName and returns Country Details

type: json | ICountry

{
    "id": "4",
    "sortname": "AS",
    "name": "American Samoa",
    "phonecode": "1684"
}

getStateByName(name)

It accepts a valid StateName and returns State Details

type: json | ICountry

{
    "id": 4119,
    "name": "Midlands",
    "country_id": "246"
}

getCityByName(name)

It accepts a valid CityName and returns City Details

type: json | ICity

{
    "id": "3",
    "name": "Port Blair",
    "state_id": "1"
}