diff --git a/app/templates/agent-list.php b/app/templates/agent-list.php index c79c468..d37b5d3 100644 --- a/app/templates/agent-list.php +++ b/app/templates/agent-list.php @@ -21,13 +21,12 @@ $jwt = $agentObject->generateAgentToken($payload, $agent['secret_key']); ?> - - + + - +

-

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 {