From 1ee4f9cf1c341075acd327a493b1ef152e353cb2 Mon Sep 17 00:00:00 2001 From: Cristian Mitre Date: Wed, 20 Nov 2024 14:28:24 +0200 Subject: [PATCH] refactor adding query parameters in commerce.js --- scripts/commerce.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/commerce.js b/scripts/commerce.js index 645ca47455..08da9a8d20 100644 --- a/scripts/commerce.js +++ b/scripts/commerce.js @@ -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; }