country-state-city-plus
v1.1.1
Published
Library for fetching Country, its States and Cities forked from country-state-city
Downloads
100
Maintainers
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"
}