πŸ“£ The forum has moved to GitHub

We’ve switched to GitHub Discussions as the hub for our community. This will improve the experience of collaborating for everyone, sharing what you’re working on, and discussing ideas for how Swell can be improved. Existing threads will remain open, but new posts are disabled.

Go to GitHub β†’

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.