Skip to content

Commit

Permalink
fix request&settings test
Browse files Browse the repository at this point in the history
  • Loading branch information
3ch023 committed Aug 12, 2024
1 parent 4f7e010 commit 6fcdf15
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 44 deletions.
15 changes: 13 additions & 2 deletions libs/features/mas/commerce/src/wcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,19 @@ export function Wcs({ settings }) {
try {
log.debug('Fetching:', options);
options.offerSelectorIds = options.offerSelectorIds.sort();
const url = `${settings.wcsURL}?offer_selector_ids=${options.offerSelectorIds}&country=${options.country}&language=${options.language}&locale=${options.locale}&api_key=${apiKey}&landscape=${env === Env.STAGE ? 'ALL' : settings.landscape}`;
const response = await fetch(url);
const url = new URL(settings.wcsURL);
url.searchParams.set('offer_selector_ids', options.offerSelectorIds.join(','));
url.searchParams.set('country', options.country);
url.searchParams.set('language', options.language);
if (options.currency) {
url.searchParams.set('currency', options.currency);
}
url.searchParams.set('locale', options.locale);
url.searchParams.set('promotion_code', options.promotionCode);
url.searchParams.set('landscape', env === Env.STAGE ? 'ALL' : settings.landscape);
url.searchParams.set('api_key', apiKey);

const response = await fetch(url.toString());
if (response.ok) {
const data = await response.json();
log.debug('Fetched:', options, data);
Expand Down
Loading

0 comments on commit 6fcdf15

Please sign in to comment.