Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/addsearch-js-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "addsearch-js-client",
"version": "0.8.10",
"version": "0.8.11",
"description": "AddSearch API JavaScript client",
"main": "index.js",
"jsdelivr": "./dist/addsearch-js-client.min.js",
Expand Down
18 changes: 11 additions & 7 deletions src/apifetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
}

}
api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs;
}

// Suggest
Expand All @@ -154,6 +155,7 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
qs = settingToQueryParam(settings.suggestionsSize, 'size') +
settingToQueryParam(settings.lang, 'lang');
kw = settings.suggestionsPrefix;
api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs;
}

// Autocomplete
Expand All @@ -162,18 +164,20 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
qs = settingToQueryParam(settings.autocomplete.field, 'source') +
settingToQueryParam(settings.autocomplete.size, 'size');
kw = settings.autocomplete.prefix;
api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs;
}

else if (type === 'recommend') {
apiPath = 'recommendations';
qs = settingToQueryParam(recommendOptions.itemId, 'itemId');
if (recommendOptions.type === 'RELATED_ITEMS') {
qs = settingToQueryParam(recommendOptions.itemId, 'itemId');
apiPath = 'recommendations/index/' + sitekey + '/block/' + recommendOptions.blockId + '?' + qs;
} else if (recommendOptions.type === 'FREQUENTLY_BOUGHT_TOGETHER') {
qs = settingToQueryParam(recommendOptions.itemId, 'itemId');
apiPath = 'recommendations/' + sitekey + '?configurationKey=' + recommendOptions.configurationKey + qs;
}
api = 'https://' + apiHostname + '/v1/' + apiPath;
}

// Execute API call
api = type === 'recommend' ?
'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?configurationKey=' + recommendOptions.configurationKey + qs :
'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs;

apiInstance.get(api)
.then(function(response) {
var json = response.data;
Expand Down