jeudi 9 avril 2015

Ember.js - Not sure how to model data

I'm using the RESTAdapter from Ember data to work with a JSON payload. Part of the payload contains data such as



"links": {
"facebook": "http://ift.tt/1FocBDV",
"twitter": "http://ift.tt/VisB5f",
"officialWebsite": "http://ift.tt/q88H9a"
},


I'm not really sure how to model the data. I noticed that the RESTSerializer has a normalizePayload function, so I figured I'd give that a shot instead of the RESTAdapter. I used it like so



normalizePayload: function(payload) {
payload.facebookUrl = payload.links.facebook;
payload.twitterUrl = payload.links.twitter;
payload.mySpaceUrl = payload.links.myspace;
payload.officialWebsiteUrl = payload.links.officialWebsite;
delete payload.links;
return payload;
}


Problem with this approach is the RESTSerializer doesn't support the findQuery method, which I rely on. I get an error saying tried to load a query but your adapter does not implement findQuery


Any help on this would be greatly appreciated.





Aucun commentaire:

Enregistrer un commentaire