diff --git a/blocks/adp-infinite-results-campaign-collections/CollectionsDatasource.js b/blocks/adp-infinite-results-campaign-collections/CollectionsDatasource.js index 94108fa7..d24c156c 100644 --- a/blocks/adp-infinite-results-campaign-collections/CollectionsDatasource.js +++ b/blocks/adp-infinite-results-campaign-collections/CollectionsDatasource.js @@ -20,7 +20,8 @@ export default class CollectionsDatasource { this.pageNumber += 1; - const list = await listCampaignCollections('gmo-campaignName:Everyone Can', '108396-1046543',pageNumber); + //Todo Pass in the campaignName + const list = await listCampaignCollections('gmo-campaignName:Everyone Can',pageNumber); if (this.pageNumber >= list.nbPages){ this.lastPage = true; @@ -45,7 +46,8 @@ export default class CollectionsDatasource { this.infiniteResultsContainer = infiniteResultsContainer; this.container = container; - const list = await listCampaignCollections('gmo-campaignName:Everyone Can', '108396-1046543',this.pageNumber); + //Todo Pass in the campaignName + const list = await listCampaignCollections('gmo-campaignName:Everyone Can',this.pageNumber); infiniteResultsContainer.resultsCallback( container, diff --git a/scripts/collections.js b/scripts/collections.js index 906e99bf..d87ce9c5 100644 --- a/scripts/collections.js +++ b/scripts/collections.js @@ -1,5 +1,6 @@ import { getBearerToken } from './security.js'; import { + getSearchIndex, getAssetHandlerApiKey, getDeliveryEnvironment, getBackendApiKey, @@ -292,11 +293,13 @@ export async function searchListCollection(limit = undefined, page = 0) { * @returns {Promise} A promise that resolves with a list of collections. * @throws {Error} If an HTTP error or network error occurs. */ -export async function listCampaignCollections(campaignName, indexName, page = 0) { +export async function listCampaignCollections(campaignName, page = 0) { // Construct the query parameters const queryParams = new URLSearchParams(); + const indexName = getSearchIndex(); + if (campaignName) { queryParams.append('campaignName', campaignName); }