Skip to content

getCurrentCountry(): Promise<UserCountry>

The getCurrentCountry method retrieves the ISO country code based on the origin of the user's request.

Returned value

A returned value has a type of Promise<UserCountry> where UserCountry represents the UserCountry model documentation.

Example

In this example we make a UserApi call to get the current user country.

    useStorefront(async (storefront) => {
        const userApi = await storefront.getApi('UserApi');

        const countryObject = await userApi.getCurrentCountry();

        console.log('user\'s current country:', countryObject.country)
    });

User API methods reference

Models reference