Reference · On-demand subdivisions
loadSubdivisionsfunction
The subdivisions of one country, every level, in code order: the same list as
Import it
import { loadSubdivisions } from "@johnmorrisdotca/kuni/load";
Definition
function loadSubdivisions(countryCode: string): Promise<readonly Subdivision[] | null>
Parameters
| Name | Type | Description |
|---|---|---|
countryCode | string | An alpha-2 code, either case. |
Returns
Promise<readonly Subdivision[] | null>
The list, frozen; an empty list for a country that has none (Antarctica); null for a code that is not
a country.
Examples
import { loadSubdivisions } from "@johnmorrisdotca/kuni/load";
console.log((await loadSubdivisions("CA"))?.length); // 13
console.log((await loadSubdivisions("jp"))?.[12].name.ja); // "東京都"
console.log(await loadSubdivisions("AQ")); // []
console.log(await loadSubdivisions("XX")); // null13
東京都
[]
nullWhat it prints (run when this page was built)