selectCountryByCode$(code: string): Observable<Country | null>¶
The selectCountryByCode$
method allows you to get the observable with 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 select.
Returned value¶
A returned value has a type of Observable<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.selectCountryByCode$('VN');
country$.subscribe((country) => {
console.log('country with VN code:', country);
});
});
Storefront Settings API methods reference¶
- getSkinSettings
- getPageSettings
- selectSkinSettings$
- selectPageSettings$
- selectFrontstoreApiUrl$
- getLocales
- selectLocales$
- getCountries
- selectCountries$
- getCountryById
- selectCountryById$
- getCountryByCode