jeudi 8 septembre 2016

Handling errors with Ember Data JSON-API adapter not working

I have a problem Handling errors using JSON-API, I done all steps like wrote in documentation but it's doesn't works.

I have model:

 var user = this.get('store').createRecord('user', {
    'email': 'test@test.com',
    'name': 'Lorem ipsum',
    'password': '123',
  });

  user.save().then(function(){
    ...
  }).catch(function(data){
    console.log(user.get('errors'), data);
    // data is ErrorClass  with deserialize errors inside
  });

And API responce (422 Unprocessable Entity):

    {  
   "errors":[  
      {  
         "detail":"Email address must be between 6 and 128 characters in length",
         "source":{  
            "pointer":"/data/attributes/password"
         }
      }
   ]
   }

In this case isError flag is false, user.get('errors') -> empty

I also tried response with 500 Internal Server Error code

In this case isError flag is true (as expected) and error object contain in adapterError

So what I'm doing wrong or what try to check, thanks in advance




Aucun commentaire:

Enregistrer un commentaire