samedi 19 décembre 2015

Ember.js adapter/serializer configuration for legacy API

I am trying to get a new Ember 2.2 application to talk to a legacy API server. I can not change server code so trying to figure out how to customise Ember Data to handle the models well.

The issue is that server APIs return a JSON like this for every kind of models:

{ content: [ {id: 1, title: "a"}, {id: 2, title: "b"}, meta: {...} ]

I would use JSONAPISerializer if the server used a different root for each model instead of the content key. I would use JSONSerializer if the response was just a plain array (i.e. no content key in it at all). But I do not see a way to get it to work with the response above.

What would be your suggestion?




Aucun commentaire:

Enregistrer un commentaire