1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-21 22:09:36 +02:00

remove image

This commit is contained in:
Sean Morley 2024-08-17 13:59:49 -04:00
parent 9c75af5b7f
commit 6b9cd48603
2 changed files with 28 additions and 15 deletions

View file

@ -39,12 +39,13 @@
}
async function removeImage(id: string) {
let res = await fetch(`/api/images/${id}/`, {
method: 'DELETE'
let res = await fetch(`/api/images/${id}/image_delete`, {
method: 'POST'
});
let data = await res.json();
if (data.id) {
if (res.status === 204) {
images = images.filter((image) => image.id !== id);
adventureToEdit.images = images;
console.log(images);
addToast('success', 'Image removed');
} else {
addToast('error', 'Failed to remove image');