1.1.1 • Published 4 years ago

country-state-city-plus v1.1.1

Weekly downloads
5
License
GPL-3.0
Repository
github
Last release
4 years ago

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"
}