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 ({ eventBus, getApi }) => {
    eventBus.on('basket.initialized', async () => {
        const basketShippingsApi = await getApi('basketShippingsApi');

        await basketShippingsApi.setCountry(2);
    });
});

Basket Address API methods reference