I'm using ember-data, and want to trap and display any errors returned by the rest adapter. I looked at the question here
I added the following code to my model definition:
becameInvalid: function(errors) {
alert ("here" + errors);
},
and the rest adapter returns a 422 (Unprocessable Entity) code
however, the alert doesn't show. Am I missing something, or just being a real newbie numpty?
update #1:
making some progress. The rest server returns the following Json:
{"errors":{ "lastName": ["LastName cannot be blank"] }}
the model has
becameInvalid: function(errors) { console.log(JSON.stringify(errors)); },
however, the console now has the following:
{"email":"jmls@foo,com","firstName":"Julian","id":"aa7c4b42-df64-8fb8-d213-0ad81c9bc213","lastName":"","notes":"ccc"}
which seems to be the json of the record itself, not of the errors.
How can I get to the errors? I have tried
console.log(errors.get("errors.lastName")
but get undefined.