mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-21 22:09:36 +02:00
remove image
This commit is contained in:
parent
9c75af5b7f
commit
6b9cd48603
2 changed files with 28 additions and 15 deletions
|
@ -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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue