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

getSearchSuggestions

Method fetching a list of available search suggestions from SAP Commerce Cloud.

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

Signature

export declare function getSearchSuggestions<Res extends SuggestionList = SuggestionList,
	Props extends SearchSuggestionsProps = SearchSuggestionsProps>(
	props: Props,
	options?: MethodOptions
): Promise<Res>;

Parameters

NameRequiredTypeDescription
propsRequiredPropsParameter 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 representation of a Suggestion List.

Referenced Types

Examples

Fetching suggestions for a specific searchTerm.

import { sdk } from '~/sdk';

const suggestions = await sdk.commerce.getSearchSuggestions({ searchTerm: 'shirt' });

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

import { sdk } from '~/sdk';

const suggestions = await sdk.commerce.getSearchSuggestions({ searchTerm: 'shirt', lang: 'en', currency: 'GBP' });

Limiting the number of search suggestions by using the max parameter.

import { sdk } from '~/sdk';

const suggestions = await sdk.commerce.getSearchSuggestions({ searchTerm: 'shirt', max: 3 });

On this page