Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialising HTTP error response #84

Open
prudnikov opened this issue May 20, 2018 · 0 comments
Open

Deserialising HTTP error response #84

prudnikov opened this issue May 20, 2018 · 0 comments

Comments

@prudnikov
Copy link

Usually when using JSON REST API error response contain dictionary where keys are the same as model's keys, but values are error messages.

For example

export class User {
  @deserialize id: number;
  @autoserializeAs('first_name') firstName: string;
  @autoserializeAs('last_name') lastName: string;
}

When failed updating User instance we may receive an error response

{first_name:['Min length is 2 characters']}

This is default behaviour in Django Rest Framework and I assume in many more.

Is there any way to deserialise error response, so when we get the error data object in the application we work with internal keys (firstName) instead of API keys (first_name)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant