Skip to content

Commit

Permalink
missing authorization headers issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuldip committed Sep 13, 2023
1 parent b32959d commit 167de90
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions resources/js/tryitout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 167de90

Please sign in to comment.