formatAddress()function
formatAddress({ address1, address2, city, state, postcode, country }: AddressData): string| Param | Type | |
|---|---|---|
address | AddressData | The address data to format. required |
.address1 | string | required readonly |
.address2 | string | required readonly |
.city | string | required readonly |
.state | string | required readonly |
.postcode | string | required readonly |
.country | Country | Two-letter ISO 3166-1 alpha-2 country code string (a key of COUNTRIES). required readonly |
| Return | |
|---|---|
string | A newline-separated address string. |
Format address data into a single multiline string.
- Each field is placed on its own line; an empty
address2is omitted. - The country code is expanded to its full name via
formatCountry().
Examples
formatAddress({ address1: "1 High St", address2: "", city: "London", state: "", postcode: "SW1", country: "GB" })