delete uploaded file

This commit is contained in:
Takeshi Kimata
2024-03-17 20:15:54 +09:00
parent d94af046c0
commit 1825545bf0
4 changed files with 87 additions and 2 deletions

View File

@@ -129,4 +129,35 @@ async function fetchCreateAttachments(caseId: number, files: File[]) {
}
}
export { fetchCase, fetchCreateStep, fetchDeleteStep, updateCase, fetchCreateAttachments };
/**
* delete attachment
*/
async function fetchDeleteAttachment(attachmentId: number) {
const fetchOptions = {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
};
const url = `${apiServer}/attachments/${attachmentId}`;
try {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error) {
console.error("Error deleting project:", error);
throw error;
}
}
export {
fetchCase,
fetchCreateStep,
fetchDeleteStep,
updateCase,
fetchCreateAttachments,
fetchDeleteAttachment,
};