fix: Show error message from backend on create existing user (#1964)

* Show error message from backend on create existing user

* Format
This commit is contained in:
Presley Pizzo
2022-06-01 15:52:54 -04:00
committed by GitHub
parent 46ffb67d60
commit bb400a4e82
4 changed files with 28 additions and 12 deletions
+8
View File
@@ -33,6 +33,14 @@ export const isApiError = (err: any): err is ApiError => {
return false
}
/**
* ApiErrors contain useful error messages in their response body. They contain an overall message
* and may also contain errors for specific form fields.
* @param error ApiError
* @returns true if the ApiError contains error messages for specific form fields.
*/
export const hasApiFieldErrors = (error: ApiError): boolean => Array.isArray(error.response.data.errors)
export const mapApiErrorToFieldErrors = (apiErrorResponse: ApiErrorResponse): FieldErrors => {
const result: FieldErrors = {}