Skip to content
Snippets Groups Projects
Commit b75816b3 authored by Tore.Brede's avatar Tore.Brede
Browse files

Fixing problem with missing error message

parent 383b4285
No related branches found
No related tags found
1 merge request!209Fixing problem with missing error message
Pipeline #104489 passed
......@@ -96,15 +96,29 @@ export default function StepRegistration() {
fetch('/api/ui/v1/invite/', submitJsonOpts('POST', payload))
.then((res) => {
if (!res.ok) {
res.text().then((text) => {
setSubmitState(SubmitState.SubmitFailure)
setSubmitErrorReport({
errorHeading: t('error.invitationCreationFailedHeader'),
statusCode: res.status,
statusText: res.statusText,
errorBodyText: text,
// Try to extract data from body of error message
res
.text()
.then((text) => {
setSubmitState(SubmitState.SubmitFailure)
setSubmitErrorReport({
errorHeading: t('error.invitationCreationFailedHeader'),
statusCode: res.status,
statusText: res.statusText,
errorBodyText: text,
})
})
.catch((error) => {
// Extracting data from body failed, just show an error message with no body text
console.error('error', error)
setSubmitErrorReport({
errorHeading: t('error.invitationCreationFailedHeader'),
statusCode: res.status,
statusText: res.statusText,
errorBodyText: undefined,
})
setSubmitState(SubmitState.SubmitFailure)
})
})
} else {
return res.text()
}
......@@ -118,7 +132,7 @@ export default function StepRegistration() {
}
})
.catch((error) => {
console.log('error', error)
console.error('error', error)
setSubmitState(SubmitState.SubmitFailure)
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment