diff --git a/src/routes/ImagePost.svelte b/src/routes/ImagePost.svelte index 711fb6f806b58af30bf4eae243ae3ed93bb0ba18..fbb41cd90fc57c65200a5eb3b1094225b1eb4292 100644 --- a/src/routes/ImagePost.svelte +++ b/src/routes/ImagePost.svelte @@ -53,15 +53,17 @@ fetchAPI(paths.ImageField(snowflake), options); } // Delete the image then reroute back to /browse?p=1 - // I don't know why the fuck this works but just leave it here async function deleteImage(snowflake) { if (confirm("Delete image?")) { const options = { method: "DELETE", headers: { secret: $user.secret }, }; - fetchAPI(paths.ImageField(snowflake), options); - push("#/browse?p=1"); + // .finally is to cope with fetchAPI resolving to error when + // an endpoint returns empty JSON + fetchAPI(paths.ImageField(snowflake), options).finally(() => + push("#/browse?p=1") + ); } } </script>