country-states-cities-module

Country State City provider

Usage no npm install needed!

<script type="module">
  import countryStatesCitiesModule from 'https://cdn.skypack.dev/country-states-cities-module';
</script>

README

Country States Cities Module

This package provides a list of all the countries, their states, and cities, and various relevant information pertaining to them.

Installation

Use the package manager npm or yarn.

pip install foobar

Usage

import {
  getAllCountries,
  getStatesByCountry,
  getCitiesByStateAndCountry,
} from "country-states-cities-module";

const testFunction = async () => {
  // returns list of all the countries in the world
  await getAllCountries().then(data => {
    console.log(data);
  });

  // returns the list of states in the country passed as an argument
  // Also note that for countries having spaces in their name, do not omit spaces.

  await getStatesByCountry("United States").then(data => {
    console.log(data);
  });

  // return the list of cities for the provided pair of Country and States
  await getCitiesByStateAndCountry("United States", "Alabama").then(data => {
    console.log(data);
  });
};

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Github: https://github.com/brigadierpratap/country-states-cities-module

Buy me a coffee

License

ISC