From a26d765344587da1a3c4e5f66a01a8c0c4b03e23 Mon Sep 17 00:00:00 2001 From: vradulescu-bd <140399829+vradulescu-bd@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:32:30 +0300 Subject: [PATCH] DEX-17982 - Pid support in fetch product api call (#463) --- solutions/scripts/utils/utils.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/solutions/scripts/utils/utils.js b/solutions/scripts/utils/utils.js index 364180c3a..dc350c097 100644 --- a/solutions/scripts/utils/utils.js +++ b/solutions/scripts/utils/utils.js @@ -48,14 +48,21 @@ async function findProductVariant(cachedResponse, variant) { * @param variant The product variant * @returns {Promise<*>} */ -export async function fetchProduct(code = 'av', variant = '1u-1y') { +export async function fetchProduct(code = 'av', variant = '1u-1y', pid = null) { const data = new FormData(); + // extract pid from url + if (!pid) { + const url = new URL(window.location.href); + // eslint-disable-next-line no-param-reassign + pid = url.searchParams.get('pid'); + } + data.append('data', JSON.stringify({ ev: 1, product_id: code, config: { extra_params: { - pid: null, + pid, }, }, }));