getCountryByCode(code: string): Country | null¶
The getCountryByCode
method allows you to get the specific country by its code if it's currently supported in a shop. Visit IBAN's list of country codes to find the specific code you need.
Input parameters¶
code¶
code
is a mandatory parameter of string
type which represents the code of a country to retrieve.
Returned value¶
A returned value has a type of Country | null
. If a country exists it returns a Country model. If it doesn't it returns null
.
Example¶
In this example we make a StorefrontSettingsApi
call to get the specific country by its code.
useStorefront(async (storefront) => {
const storefrontSettingsApi = storefront.getApiSync('StorefrontSettingsApi');
const country = storefrontSettingsApi.getCountryByCode('VN');
console.log('country with VN code:', country);
});
Storefront Settings API methods reference¶
- getSkinSettings
- getPageSettings
- selectSkinSettings$
- selectPageSettings$
- selectFrontstoreApiUrl$
- getLocales
- selectLocales$
- getCountries
- selectCountries$
- getCountryById
- selectCountryById$
- selectCountryByCode$