Ensure 'validationErrors' is checked for details field errors when parsing an error response on update

This commit is contained in:
Dean 2022-10-28 15:46:03 +01:00
parent 6719bd2c69
commit 1418790756
1 changed files with 5 additions and 1 deletions

View File

@ -70,7 +70,11 @@
.map(([key, error]) => ({ dataPath: key, message: error }))
.flat()
}
} else if (error.status === 400) {
} else if (error.status === 400 && response?.validationErrors) {
errors = Object.keys(response.validationErrors).map(field => ({
message: `${field} ${response.validationErrors[field][0]}`,
}))
} else {
errors = [{ message: response?.message || "Unknown error" }]
}
} else {