handle 400 like 500 as errors

This commit is contained in:
Thomas Ruoff
2020-09-03 00:25:21 +02:00
committed by Thomas Ruoff
parent 20c2a70206
commit f18fa3f4d8

View File

@@ -160,6 +160,18 @@ async function createBooking(formData: WizardFormData) {
referrerPolicy: 'no-referrer',
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()
}