Skip to content

selectCountryById$(id: number): Observable<Country | null>

The selectCountryById$ method allows you to get the observable with 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 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 observable with specific country by its id.

    useStorefront(async (storefront) => {
        const storefrontSettingsApi = storefront.getApiSync('StorefrontSettingsApi');

        const country$ = storefrontSettingsApi.selectCountryById$(12);

        country$.subscribe((country) => {
            console.log('name of the retrieved country:', country.name);
        });
    });

Storefront Settings API methods reference

Models reference