// function for checkbox click
function updatePermission(checkbox) {
const PermissionId = parseInt(checkbox.id);
const RoleId = getqsValue();
updatePermAPI(PermissionId, RoleId);
}
// get role id
function getqsValue() {
const urlParm = new URLSearchParams(window.location.search);
return urlParm.get('id');
}
function updatePermAPI(PermissionId, RoleId) {
const permUrl = `${window.location.origin}/api/roles/updatepermission`;
const method = "POST";
const data = {
PermissionId: PermissionId,
RoleId: RoleId
}
console.log("API URL:", permUrl); // Log the complete API URL
fetch(permUrl, {
method: method,
body: JSON.stringify(data),
headers: {
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => {
console.log(data); // Log the response data
})
.catch(error => {
console.error(error); // Log the error
});
}
Calling an passing data to a POST API
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment