costapy/static/js/roles.js

20 lines
699 B
JavaScript

var token = document.getElementById("form-token" ).value;
const lister = document.getElementById("lister");
sendHttpRequest("/api/auth/roles/list", "POST", null,
function (error, response) {
if (error) console.error("Error:", error);
else {
console.log("JSON Response:", response);
const ls = JSON.parse(response);
ls.data.forEach(data => {
const itemElement = document.createElement("div");
postElement.innerHTML = `<li>[${data.id}] ${data.name}: ${data.count} User(s)</li>`;
lister.appendChild(itemElement);
});
}
}, "application/json", `Bearer ${token}`
);