From 167de908cebf5bbfc83923b85a8011e763cfa8ba Mon Sep 17 00:00:00 2001 From: Kuldip Date: Wed, 13 Sep 2023 16:31:00 +0530 Subject: [PATCH] missing authorization headers issue fixed --- resources/js/tryitout.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/js/tryitout.js b/resources/js/tryitout.js index a3feb1bd..0a92f49c 100644 --- a/resources/js/tryitout.js +++ b/resources/js/tryitout.js @@ -231,8 +231,12 @@ async function executeTryOut(endpointId, form) { const urlParameters = form.querySelectorAll('input[data-component=url]'); urlParameters.forEach(el => (path = path.replace(new RegExp(`\\{${el.name}\\??}`), el.value))); - const headers = Object.fromEntries(Array.from(form.querySelectorAll('input[data-component=header]')) - .map(el => [el.name, el.value])); + const headers = JSON.parse(form.dataset.headers); + // Check for auth param that might go in header + if (form.dataset.authed === "1") { + const authHeaderEl = form.querySelector('input[data-component=header]'); + if (authHeaderEl) headers[authHeaderEl.name] = authHeaderEl.dataset.prefix + authHeaderEl.value; + } // When using FormData, the browser sets the correct content-type + boundary let method = form.dataset.method;