Created
June 14, 2025 03:08
-
-
Save andreburto/323b3b1f1ad898297da626c3bd3bda14 to your computer and use it in GitHub Desktop.
Copilot generated html page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>HTTP Request Buttons</title> | |
</head> | |
<body> | |
<h1>HTTP Request Buttons</h1> | |
<button id="putButton">Put</button> | |
<button id="getButton">Get</button> | |
<button id="deleteButton">Delete</button> | |
<script> | |
// Define the global constant for the endpoint URL | |
const endPointUrl = 'https://example.com/api'; | |
// Function to make an HTTP request | |
function makeRequest(method) { | |
fetch(endPointUrl, { method }) | |
.then(response => response.text()) | |
.then(data => console.log(`${method} Response:`, data)) | |
.catch(error => console.error(`${method} Error:`, error)); | |
} | |
// Add event listeners to the buttons | |
document.getElementById('putButton').addEventListener('click', () => makeRequest('PUT')); | |
document.getElementById('getButton').addEventListener('click', () => makeRequest('GET')); | |
document.getElementById('deleteButton').addEventListener('click', () => makeRequest('DELETE')); | |
// Timer to make a GET request every 30 seconds | |
setInterval(() => makeRequest('GET'), 30000); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment