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

response 422 code status #64

Open
denniscastro opened this issue Jun 15, 2016 · 5 comments
Open

response 422 code status #64

denniscastro opened this issue Jun 15, 2016 · 5 comments

Comments

@denniscastro
Copy link

Hi.

Good addon, but what about when response is 422 and ember return and DS.invalidError object?

@mike-north
Copy link
Owner

Please propose a concrete scenario, including what you'd attempt to persist, the response you'd expect to get back, and how you'd expect the addon to behave.

There's some automatic error handling in ember-data that goes with implementing the JSON-API standard, but this is a more general addon that doesn't assume anything about your UI/API contracts

@malina
Copy link

malina commented Jul 13, 2016

If i use default ember action save

someModel.set('someField', 'someValue');
someModel.save();

And if response is 422 than model has errors.

someModel.get('errors).someField  // error object with message from server

And if i use custom action

someModel.customAction({someField: 'someValue'});

And if response is 422 than model has no errors.

someModel.get('errors).someField  // is null

@denniscastro
Copy link
Author

Yes.. You need to push the response.errors to Ds.invalidErrors and/or Ds.Error

@mike-north
Copy link
Owner

This is beyond the scope of this addon. ember-api-actions makes no assumptions about the nature of your payload (i.e., whether you're passing a model to your API at all), so handling validation errors wouldn't make sense as a default.

What we could do is provide a standard pattern for dealing with errors in the README

@Exelord
Copy link

Exelord commented Feb 6, 2017

@denniscastro to get this behavior works check my package with implemented push to store option.
https://github.com/Exelord/ember-custom-actions/

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

4 participants