From 4644a93d2d841c80c2142f96467838b74978ad1e Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Sat, 18 Jan 2025 17:27:54 +0100 Subject: [PATCH] :coffin: [open-formulieren/open-forms#4929] Delete dead code The error handling of the post method is obsoleted because the apiCall helper itself already calls throwForStatus which results in an exception if/when response.ok is false, so this block of code will never execute. This also further simplifies the helper to directly return the status URL, which is the only bit of relevant information returned by the API endpoint. --- src/components/Summary/SubmissionSummary.jsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/components/Summary/SubmissionSummary.jsx b/src/components/Summary/SubmissionSummary.jsx index 5f22c1dc5..8d77082dd 100644 --- a/src/components/Summary/SubmissionSummary.jsx +++ b/src/components/Summary/SubmissionSummary.jsx @@ -17,13 +17,8 @@ import {loadSummaryData} from './utils'; const completeSubmission = async (submission, statementValues) => { const response = await post(`${submission.url}/_complete`, statementValues); - if (!response.ok) { - console.error(response.data); - // TODO Specific error for each type of invalid data? - throw new Error('InvalidSubmissionData'); - } else { - return response.data; - } + const {statusUrl} = response.data; + return statusUrl; }; const SubmissionSummary = () => { @@ -59,8 +54,7 @@ const SubmissionSummary = () => { if (refreshedSubmission.submissionAllowed !== SUBMISSION_ALLOWED.yes) return; let statusUrl; try { - const responseData = await completeSubmission(refreshedSubmission, statementValues); - statusUrl = responseData.statusUrl; + statusUrl = await completeSubmission(refreshedSubmission, statementValues); } catch (e) { setSubmitError(e.message); return;