Skip to content

setCountry(countryId: number) Promise<void>

The setCountry is an asynchronous method that allows to set the current shipping country by id.

Returned value

A returned value has a type of Promise<void> as this method returns nothing.

Event Bus events

This API method dispatches the following events with the Event Bus:

Example

In this example we make a basketShippingsApi call to set the current shipping country by id.

useStorefront(async (storefront) => {
    let basketShippingsApi = storefront.getApiSync('basketShippingsApi');

    if (!basketShippingsApi) {
        const featureSystemApi = this.getApiSync(FEATURE_SYSTEM_API_NAME);
        await featureSystemApi.registerDynamic('basket');

        basketShippingsApi = storefront.getApiSync('basketShippingsApi');
    }

    await basketShippingsApi.setCountry(2);
});

Basket Address API methods reference