mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
handle 400 like 500 as errors
This commit is contained in:
committed by
Thomas Ruoff
parent
20c2a70206
commit
f18fa3f4d8
@@ -160,6 +160,18 @@ async function createBooking(formData: WizardFormData) {
|
|||||||
referrerPolicy: 'no-referrer',
|
referrerPolicy: 'no-referrer',
|
||||||
body: JSON.stringify(formData),
|
body: JSON.stringify(formData),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (response.status === 400) {
|
||||||
|
const error = await response.json()
|
||||||
|
throw Error(error.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw Error(
|
||||||
|
'Sorry, konnte nicht gespeichert werden. Bitte versuch es später nochmal!'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return response.json()
|
return response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user