Spaces:
Running
Running
File size: 743 Bytes
3d8c947 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
document.getElementById("addCreditForm").addEventListener("submit", async function(e) {
e.preventDefault();
const username = document.getElementById("username").value;
const credits = parseInt(document.getElementById("credits").value, 10);
// Prompt for the admin API key
const apiKey = prompt("Enter your admin API key:");
const response = await fetch("/admin/add_credit", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": apiKey
},
body: JSON.stringify({ username, credits })
});
const result = await response.json();
document.getElementById("result").innerText = JSON.stringify(result, null, 2);
});
|