You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x
getCountries
Get available shipping/billing countries from SAP Commerce Cloud.
This method receives data from the getCountries endpoint exposed by the SAP OCC API Countries Controller.
Signature
export declare function getCountries(
context: SapccIntegrationContext,
props?: GetCountriesProps
): Promise<CountryList>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | SapccIntegrationContext | |
props | Optional | GetCountriesProps | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
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' });