dimanche 14 août 2016

How to display errors in Ember

I want to display errors in my route, but somehow this does not work :(

If an error occurs, my servers is responding with a 422 - Unprocessable Entity and the following JSON:

{
    "errors": [
        {
            "detail": "Placeholder for error detail",
            "source": {
                "pointer": "data/attributes/name"
            }
        }
    ]
}

In my route I managed to log the error in the console, but not to display it in my template:

My Route's controller looks like this:

/app/routes/ean.js
export default Ember.Route.extend({
    actions: {
        error(error, transition){
            console.log(error.errors[0].detail);
        }
    }
});

(I have left out my model and the import statements to simplify this question).

This is how I try to display the error message in my template

/app/templates/ean.hbs

    <p>


So does anybody see what I have done wrong or has any other suggestions to solve my problem?




Aucun commentaire:

Enregistrer un commentaire