States Data
Get All States
This gives you an array of all states.
ES6 Module
states.ts
import { States } from 'countries-geo';
console.log(States.getAll);
// Logs all States (e.g., [{ iso: "GH-AA", name: "Greater Accra" }, ...])
By default this is sorted by name.
Get All States sorted by isoCode
This gives you an array of all states specifically sorted by isoCode.
ES6 Module
states.ts
import { States } from 'countries-geo';
console.log(States.sortByIsoCode);
// Logs all States (e.g., [{ iso: "GH-AA", name: "Greater Accra" }, ...])
By default this is sorted by iso.
Get States by Country
This gives you an array of all states filtered by a Country isoCode.
ES6 Module
states.ts
import { States } from 'countries-geo';
console.log(States.getByCountry('GH'));
// Logs all States (e.g., [{ iso: "GH-AA", name: "Greater Accra" }, ...])
By default this is sorted by name.
Get States by Continent
This gives you an array of all states filtered by a Continent isoCode.
ES6 Module
states.ts
import { States } from 'countries-geo';
console.log(States.getByContinent('AF'));
// Logs all States (e.g., [{ iso: "GH-AA", name: "Greater Accra" }, ...])
By default this is sorted by name.
Last updated on