Skip to content

Commit

Permalink
refactor adding query parameters in commerce.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mitre10 committed Nov 20, 2024
1 parent ff694c9 commit 1ee4f9c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions scripts/commerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ query($sku: String!) {

export async function commerceEndpointWithQueryParams() {
// Set Query Parameters so they can be appended to the endpoint
const queryParameters = new URLSearchParams();
queryParameters.append('Magento-Environment-Id', await getConfigValue('commerce-environment-id'));
queryParameters.append('Magento-Website-Code', await getConfigValue('commerce-website-code'));
queryParameters.append('Magento-Store-View-Code', await getConfigValue('commerce-store-view-code'));
queryParameters.append('Magento-Store-Code', await getConfigValue('commerce-store-code'));
queryParameters.append('Magento-Customer-Group', await getConfigValue('commerce-customer-group'));
const urlWithQueryParams = new URL(await getConfigValue('commerce-endpoint'));
urlWithQueryParams.search = queryParameters.toString();
urlWithQueryParams.searchParams.append('Magento-Environment-Id', await getConfigValue('commerce-environment-id'));
urlWithQueryParams.searchParams.append('Magento-Website-Code', await getConfigValue('commerce-website-code'));
urlWithQueryParams.searchParams.append('Magento-Store-View-Code', await getConfigValue('commerce-store-view-code'));
urlWithQueryParams.searchParams.append('Magento-Store-Code', await getConfigValue('commerce-store-code'));
urlWithQueryParams.searchParams.append('Magento-Customer-Group', await getConfigValue('commerce-customer-group'));
return urlWithQueryParams;
}

Expand Down

0 comments on commit 1ee4f9c

Please sign in to comment.