Returning errors from Storefront API registration

I've found a behavior in the account creation flow that is confusing, or maybe a bug.

When I try to register a user that is already registered, the endpoint returns a Validation Error like this

{
    "email": {
        "message":"Already exists",
        "code":"UNIQUE",
        "fields": { 
            "email":"[email protected]"
        }
    }
}

This differs from the Validation Error described (and used) on the backend, ie:

{
    "errors": {
        "email": {
            "code": "FORMAT_EMAIL",
            "message": "Must be a valid email address"
        }
    }
 }

the "errors" property make a great difference: I just need to check if the return value has the errors property instead of checking one by one the fields for a property (for example message).

The current format of Validation Error returned from the storefront api makes it very difficult to handle.

Answers

Sign In or Register to comment.