mercredi 29 juillet 2015

Ember data Rest adapter error handling not working

I have a basic Ember app and I am trying to handle validation errors on save (model is using the REST Adapter). In my route I am doing:

task.save().then(
                function() {alert("success");},
                function() {alert("fail");}
                ).catch(
                    function() {alert("catch error");}
                    );

When the record is valid I get the "success" alert, but when record is invalid, I do not get the "fail" alert OR "catch error". In the console I get:

POST http://localhost:8080/api/tasks 422 (Unprocessable Entity)
Error: The adapter rejected the commit because it was invalid

The response from the api look like this:

{"errors":{"name":["can't be blank"],"parent_task":[]}}

I am using Ember Data 1.13.




Aucun commentaire:

Enregistrer un commentaire