Skip to content

Registration API responses are stringified JSON objects

On POST /api/v1/accounts, it returns error messages as stringified JSON. I have to JSON.parse(response.data.error) to do anything with them.

Screenshot_from_2020-09-29_22-59-59

Usually when there's an error key it's just a regular sentence, like this 403 from /oauth/token. Here is what I consider a "good" response:

Screenshot_from_2020-09-29_22-59-47

("identifier" is also good for i18n)

And the resulting popup:

Screenshot_from_2020-09-29_22-54-23

However with stringified JSON, we get this:

Screenshot_from_2020-09-29_22-54-06

What I really want to do is update the form with these values and say something generic in the popup. I think ideally the response should resemble this:

{
  "error": "Please review the submission",
  "identifier": "review_submission",
  "fields": {
    "captcha": ["Invalid CAPTCHA"]
  }
}