From 789d241769a5033aa3b1de9bbb93fdecc13aa812 Mon Sep 17 00:00:00 2001 From: Phill Pover Date: Mon, 7 Apr 2025 11:10:10 +0100 Subject: [PATCH] Pushing errors back to frontend --- frontend/src/app/album/page.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/album/page.tsx b/frontend/src/app/album/page.tsx index 5f9b439..583da48 100644 --- a/frontend/src/app/album/page.tsx +++ b/frontend/src/app/album/page.tsx @@ -46,12 +46,15 @@ export default function Page() { const formData = new FormData(event.currentTarget); try { if (formData.get('id') == "") { - await createAlbum(formData); - handleSnackbar(`Successfully created Album with ID ${formData.get("id")}`, true); + const result = createAlbum(formData) + .then(respose => {return response.json()}) + .catch(error => {response.json()}); } else { - await updateAlbum(formData); - handleSnackbar(`Successfully updated Album with ID ${formData.get("id")}`, true); + const result = await updateAlbum(formData) + .then(respose => {return response.json()}) + .catch(error => {response.json()}); } + handleSnackbar(`Successfully updated Album with ID ${formData.get("id")}: ${result}`, true); revalidateAlbums(); const data = await getAlbums(); setAlbums(data);