How can do you handle errors from backend in ember-data 14 RESTAdapter? And is there a specific formatting for the JSON response?
1 Like
the formating to json I think is like rails output. something like http://emberjs.com/guides/getting-started/using-fixtures/
I was asking about the errors. Is there a specific formatting like should the root be error, errors, or model…etc
2 Likes
Did you ever work out what the best way to return errors from a backend was? I’m starting a new project and would love to know!
I’m using reason.responseJSON.errors, where i can pass anything from message: "hooray", to objects "email": ["invalid format"].
content.send().fail (reason) ->
reason.responseJSON.errors
@joeserg Ember data works using this format with ActiveModelSerializer. Not sure about the default.
{
errors: {
email: ['is already taken'],
password: ['is missing']
}
}
in your template you can just access it by errors.email and in .fail (reason) promise you can access it via reason.errors.email
Hope this helps