Alokai
You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x

getCountries

Method fetching available shipping/billing countries from SAP Commerce Cloud.

This method sends a GET request to the getCountries endpoint of the Alokai Middleware. In turn, it receives data from the getCountries endpoint exposed by the SAP OCC API Countries Controller.

Signature

export declare function getCountries<Res extends CountryList = CountryList,
	Props extends GetCountriesProps = GetCountriesProps>(
	props?: Props,
	options?: MethodOptions
): Promise<Res>;

Parameters

NameRequiredTypeDescription
propsOptionalPropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.
optionsOptionalMethodOptionsOptions that can be passed to additionally configure the request or customize the logic in a plugin.

Returns

Returns a list of countries.

Referenced Types

Examples

Calling the method without any params to fetch a list of all available countries.

import { sdk } from '~/sdk';

const category = await sdk.commerce.getCountries();

Using the method the way it will be possible to cache the response.

import { sdk } from '~/sdk';

const category = await sdk.commerce.getCountries({ lang: 'en', currency: 'GBP' });

Fetching a list of all available countries and selecting response fields.

import { sdk } from '~/sdk';

const category = await sdk.commerce.getCountries({ fields: 'countries(isocode)' });

Fetching a list of available shipping countries.

import { sdk } from '~/sdk';

const category = await sdk.commerce.getCountries({ type: 'SHIPPING' });

Fetching a list of available billing countries.

import { sdk } from '~/sdk';

const category = await sdk.commerce.getCountries({ type: 'BILLING' });

On this page