From 4e827e62f027f3cf885d22fa2d02f1a159e933d9 Mon Sep 17 00:00:00 2001
From: Yasen Pramatarov
Result:
click a button to fetch data from the agent.diff --git a/public_html/static/agents.js b/public_html/static/agents.js index af1f435..e6ccaed 100644 --- a/public_html/static/agents.js +++ b/public_html/static/agents.js @@ -16,8 +16,8 @@ function fetchData(agent_id, url, endpoint, jwtToken, force = false) { var xhr = new XMLHttpRequest(); const agentUrl = url + endpoint; - // FIXME for debugging purpose - console.log("Requesting URL:", agentUrl); + // DEBUG show the requested URL for debugging purpose + //console.log("Requesting URL:", agentUrl); // Handle invalid URL error try { @@ -29,9 +29,8 @@ function fetchData(agent_id, url, endpoint, jwtToken, force = false) { } // send the token - xhr.setRequestHeader("Authorization", "Bearer " + jwtToken); - xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.setRequestHeader("Authorization", "Bearer " + jwtToken); // Set a timeout in milliseconds (10 seconds = 10000 ms) xhr.timeout = 10000; @@ -46,6 +45,9 @@ function fetchData(agent_id, url, endpoint, jwtToken, force = false) { try { // Parse and display the result let result = JSON.parse(xhr.responseText); + // DEBUG display the result + //console.log(xhr.responseText); + if (result.error) { resultElement.innerHTML = "Error: " + result.error; } else {