UNPKG

@empathyco/x-components

Version:
31 lines (28 loc) 1.08 kB
import { XPlugin } from '../../../../plugins/x-plugin.js'; import { createOrigin } from '../../../../utils/origin.js'; /** * Default implementation for the {@link NextQueriesActions.fetchNextQueryPreview}. * * @param context - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions, * provided by Vuex. * @param payload - The next query and the {@link FeatureLocation | location} to send in the * request. * @returns A Promise of a SearchResponse when it fetches the results, `null` if the request was * not made. */ const fetchNextQueryPreview = ({ state }, { query, location }) => { if (!query) { return null; } const origin = createOrigin({ feature: 'next_query', location }) ?? undefined; return XPlugin.adapter.search({ query, rows: state.config.maxPreviewItemsToRequest, extraParams: state.params, origin }, { id: `fetchNextQueryPreview-${query}` }); }; export { fetchNextQueryPreview }; //# sourceMappingURL=fetch-next-query-preview.action.js.map