Library for fetching Countries and States
npm install country-state-libThis is a fork of harpreetkhalsagtbit/country-state-city that excludes the cities functionality, reducing the overall bundle-size by roughly 4.2MB.
Data sourced from hiiamrohit/Countries-States-Cities-database
```
npm install country-state-lib`
or`
yarn add country-state-lib
- ES6 Module usage
`js
import csc from 'country-state-lib'
// Import Interfaces
import { ICountry, IState } from 'country-state-lib'
``
- AMD Module usage
`js`
let csc = require('country-state-lib').default
Accepts a valid CountryCode eg: 'AS' and returns Country Details
type: json | ICountry
`js`
{
"id": "4",
"sortname": "AS",
"name": "American Samoa",
"phonecode": "1684"
}
Accepts a valid CountryId and returns Country Details
type: json | ICountry
`js`
{
"id": "4",
"sortname": "AS",
"name": "American Samoa",
"phonecode": "1684"
}
Accepts a valid StateId and returns State Details
type: json | IState
`js`
{
"id": 4119,
"name": "Midlands",
"country_id": "246"
}
Accepts a valid CountryId and returns all States as Array of JSON
type: array of json | IState
`js`
[
{
"id": 4119,
"name": "Midlands",
"country_id": "246"
}
]
Returns all Countries
type: array of json | ICountry
`js``
[
{
"id": "4",
"sortname": "AS",
"name": "American Samoa",
"phonecode": "1684"
}
]