Skip to content

satyamskillz/country-states-cities-module

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

npm install country-state-cities-module

Usage

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

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

  // 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);
    })
    .catch(e => {
      console.log(e);
    });

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

  // return a detailed information about the provided Country
  await getCountry("India")
    .then(data => {
      console.log(data);
    })
    .catch(e => {
      console.log(e);
    });
};

testFunction();

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%