CountryRegionJs is a simple-to-use library that provides you with the MOST COMPREHENSIVE cascading dropdown for loading countries, associated states and substates (local governments).
Vanilla Javascript, Jest, Axios
Install CountryRegionJS
with npm
npm install CountryRegionJS
or with yarn
yarn add CountryRegionJS
Sample usage:
//import countryregionjs
import CountryRegion from "countryregionjs";
const countryRegion = new CountryRegion();
//sample ids
const countryId = 1;
const stateId = 1;
const substateId = 1;
//get all countries
const countries = await countryRegion.getCountries();
//get all statess
const states = await countryRegion.getStates(countryId);
//get all substates
const subStates = await countryRegion.getLGAs(countryId, stateId);
//get a country
const country = await countryRegion.getCountry(countryId);
//get a state
const id = 1;
const country = await countryRegion.getState(countryId, stateId);
//get a sub-state
const id = 1;
const country = await countryRegion.getLga(countryId, stateId, substateId);
A comprehensive documentation is underway💥
- Get all countries
- Get all states
- Get all local governments
- Get a country
- Get a state
- Get a local government
To run unit tests:
npm test
MIT Copyright 2023 OGUBUIKE ALEX
Contributions are always welcome!
See contributing.md
for ways to get started
Please adhere to this project's Code of Conduct .