vendredi 19 février 2016

How to access top level meta key from json-api server's 200 response when calling ember data's destroyRecord()

I'm working on an Ember app that is using Ember Data and the now default json-api adapter.

According to the json-api spec (http://ift.tt/1PLHwgj) when deleting a record your server should return a 200 response if the deletion is successful and the server responds with just a top level meta key.

My current server does just this and I'm trying to figure out how to access the data in the top level meta object when using Ember Data's model.destroyRecord() method.

myModel.destroyRecord().then(function(model){
    // the returned value is the model.  How can I get the actual metadata 
    // returned by the server?   
});

The server response contains information about what exactly was deleted and looks like this:

{
   "meta": {
      num-deleted-a: 10,
      num-deleted-b: 100,
      num-deleted-c: 200
    }
}

I'd like to get this information so I can display it to the user.

Thank you!

I am using the following versions:

Ember             : 2.2.0
Ember Data        : 2.3.3
jQuery            : 1.11.3




Aucun commentaire:

Enregistrer un commentaire