Get
일반
fetch("/api/v1/admin/notice", {
method: "GET"
})
.then(res => res.json())
.then(result => {
if (result.code === 0) {
tuiGridNotice.resetData(result.data.noticeList);
} else {
alert(result.message);
}
})
.catch(error => {
console.log(error);
});
blob
const downloadFile = (blob, name) => {
const anchorElement = document.createElement("a");
const localUrl = window.URL.createObjectURL(blob);
anchorElement.href = localUrl;
anchorElement.download = name;
anchorElement.style.display = 'none';
document.body.appendChild(anchorElement);
anchorElement.click();
document.body.removeChild(anchorElement);
window.URL.revokeObjectURL(localUrl);
}
fetch(url)
.then(res => res.blob())
.then(result => {
downloadFile(result, name);
})
.catch(error => {
alert("An error occurred during file download.");
});
Post
fetch("/api/v1/admin/notice", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(reqAdminAddNoticeDTO)
})
.then(res => res.json())
.then(result => {
alert(result.message);
if (result.code === 0) {
closeModal();
getNoticeListAndSetGridRows();
}
})
.catch(error => {
console.log(error);
});
Put
fetch("/api/v1/admin/notice", {
method: "PUT",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(reqAdminEditNoticeDTO)
})
.then(res => res.json())
.then(result => {
alert(result.message);
if (result.code === 0) {
closeModal();
getNoticeListAndSetGridRows();
}
})
.catch(error => {
console.log(error);
});
Delete
fetch("/api/v1/admin/notice/" + idx, {
method: "DELETE"
})
.then(res => res.json())
.then(result => {
alert(result.message);
if (result.code === 0) {
getNoticeListAndSetGridRows();
}
})
.catch(error => {
console.log(error);
});