@@ -146,6 +146,7 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
146146 }
147147
148148 }
149+ api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs ;
149150 }
150151
151152 // Suggest
@@ -154,6 +155,7 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
154155 qs = settingToQueryParam ( settings . suggestionsSize , 'size' ) +
155156 settingToQueryParam ( settings . lang , 'lang' ) ;
156157 kw = settings . suggestionsPrefix ;
158+ api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs ;
157159 }
158160
159161 // Autocomplete
@@ -162,18 +164,20 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
162164 qs = settingToQueryParam ( settings . autocomplete . field , 'source' ) +
163165 settingToQueryParam ( settings . autocomplete . size , 'size' ) ;
164166 kw = settings . autocomplete . prefix ;
167+ api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs ;
165168 }
166169
167170 else if ( type === 'recommend' ) {
168- apiPath = 'recommendations' ;
169- qs = settingToQueryParam ( recommendOptions . itemId , 'itemId' ) ;
171+ if ( recommendOptions . type === 'RELATED_ITEMS' ) {
172+ qs = settingToQueryParam ( recommendOptions . itemId , 'itemId' ) ;
173+ apiPath = 'recommendations/index/' + sitekey + '/block/' + recommendOptions . blockId + '?' + qs ;
174+ } else if ( recommendOptions . type === 'FREQUENTLY_BOUGHT_TOGETHER' ) {
175+ qs = settingToQueryParam ( recommendOptions . itemId , 'itemId' ) ;
176+ apiPath = 'recommendations/' + sitekey + '?configurationKey=' + recommendOptions . configurationKey + qs ;
177+ }
178+ api = 'https://' + apiHostname + '/v1/' + apiPath ;
170179 }
171180
172- // Execute API call
173- api = type === 'recommend' ?
174- 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?configurationKey=' + recommendOptions . configurationKey + qs :
175- 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs ;
176-
177181 apiInstance . get ( api )
178182 . then ( function ( response ) {
179183 var json = response . data ;
0 commit comments