From 291f4498320b2325093fb92cc9fbd9b4cb815782 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 9 Sep 2024 19:46:47 +0300 Subject: Handle post errors --- src/main/assets/scripts.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/assets/scripts.js') diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js index 1583cedc..12c4d9b2 100644 --- a/src/main/assets/scripts.js +++ b/src/main/assets/scripts.js @@ -251,6 +251,10 @@ function closeDialogListener(ev) { } } +/** + * + * @param {Response} response + */ function handleErrors(response) { if (!response.ok) { throw Error(response.statusText) @@ -310,8 +314,7 @@ function showCommentForm(mid, rid) { method: 'POST', body: formData, credentials: 'include' - }).then(handleErrors) - .then(response => response.json()) + }).then(response => response.json()) .then(result => { if (result.newMessage) { window.location.hash = `#${result.newMessage.rid}` @@ -663,8 +666,7 @@ ready(() => { method: 'POST', body: formData, credentials: 'include' - }).then(handleErrors) - .then(response => response.json()) + }).then(response => response.json()) .then(result => { if (result.newMessage) { window.location.href = new URL(`/m/${result.newMessage.mid}`, window.location.href).href -- cgit v1.2.3