getCountryById(id: number): Country | null¶
The getCountryById
method allows you to get the specific country by its id if it's currently supported in a shop.
Input parameters¶
id¶
id
is a mandatory parameter of number
type which represents the id 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 id.
useStorefront(async (storefront) => {
const storefrontSettingsApi = storefront.getApiSync('StorefrontSettingsApi');
const country = storefrontSettingsApi.getCountryById(12);
console.log('name of the retrieved country:', country.name);
});
Storefront Settings API methods reference¶
- getSkinSettings
- getPageSettings
- selectSkinSettings$
- selectPageSettings$
- selectFrontstoreApiUrl$
- getLocales
- selectLocales$
- getCountries
- selectCountries$
- selectCountryById$
- getCountryByCode
- selectCountryByCode$